Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving Functional Test With pytest Fixtures #75

Merged
merged 23 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
axiomcura marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about the future of CytoSnake testing, would it be useful to provide these datasets without the functional distinction in the directory path? For example, would these ever be used for unit or integration testing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I think that's a great idea! When I was developing this, I had no idea how the datasets should be implemented because the unit and workflow tests were not developed yet.

Empty file.
axiomcura marked this conversation as resolved.
Show resolved Hide resolved
Empty file.
412 changes: 254 additions & 158 deletions cytosnake/tests/functional/test_cli.py

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions cytosnake/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
module: test_utils.py

test_utils.py contain additional functions that enhance testing capabilities, providing
extra functionality for conducting comprehensive and robust tests.
"""


def get_raised_error(traceback: str) -> str:
"""Parses traceback and attempts to obtain raised exception error.

Traceback is parsed in this order:
1. split by new lines
2. grab the last line as it contains the raised exception and message
3. split by ":" to separate exception name and exception message
4. grab the first element since it contains that path to exception
5. split by "." and grab last element, which is the exception name

Parameters
----------
traceback : str
complete traceback generated by executing CLI

Returns
-------
str
name of raised exception error
"""

# returns exception name, refer to function documentation to understand
# the order of parsing the traceback to obtain exception name.
return traceback.splitlines()[-1].split(":")[0].split(".")[-1]
2 changes: 2 additions & 0 deletions docs/cytosnake.cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ cytosnake.cli.exec
:show-inheritance:
```

## Module contents

```{eval-rst}
.. automodule:: cytosnake.cli
:members:
Expand Down
1 change: 1 addition & 0 deletions docs/cytosnake.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
cytosnake.cli
cytosnake.common
cytosnake.guards
cytosnake.tests
cytosnake.utils
```

Expand Down
21 changes: 21 additions & 0 deletions docs/cytosnake.tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# cytosnake.tests package

axiomcura marked this conversation as resolved.
Show resolved Hide resolved
## Submodules

## cytosnake.tests.test_utils module

```{eval-rst}
.. automodule:: cytosnake.tests.test_utils
:members:
:undoc-members:
:show-inheritance:
```

## Module contents

```{eval-rst}
.. automodule:: cytosnake.tests
:members:
:undoc-members:
:show-inheritance:
```