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

Feature/test examples #284

Merged
merged 10 commits into from
Apr 13, 2021
Merged

Feature/test examples #284

merged 10 commits into from
Apr 13, 2021

Conversation

MaGering
Copy link
Collaborator

@MaGering MaGering commented Apr 12, 2021

Fix Issue #228

With this PR tests are added which check if the examples in pvcompare run.

Running with exit code == 0 leads to:

os.system("python example_to_be_tested.py") == 0

The following steps were realized, as well (required):

  • Update the CHANGELOG.md
  • Check if full simulation tests pass locally (EXECUTE_TESTS_ON=master pytest)

Also the following steps were realized (if applies):

  • Use in-line comments to explain your code
  • Write docstrings to your code
  • For new functionalities: Explain in readthedocs
  • Write test(s) for your new patch of code

Please mark above checkboxes as following:

  • Open
  • Done

In case of an error due to linting, run black . --exclude docs/ and push your changes.
Note that in case you do not fix a whole issue you should start your PR with Address #xyz.

For more information on how to contribute check the CONTRIBUTING.md.

@MaGering MaGering requested a review from SabineHaas April 12, 2021 17:12
Copy link
Collaborator

@SabineHaas SabineHaas left a comment

Choose a reason for hiding this comment

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

Thank you @MaGering for adding these tests!

As you have said yourself there are comments that need adaption.

Where do you actually run the test? Does if os.system("python " + self.elec_sector_path) == 0: run the python file?

tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
self.outputs_directory, scenario_name + "_test_run_through",
)
if os.path.exists(dir_name):
shutil.rmtree(dir_name, ignore_errors=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This part (deleting files) could be a teardown method or teardown class to avoid doubling.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done with commit 68b087b.

@MaGering
Copy link
Collaborator Author

Where do you actually run the test? Does if os.system("python " + self.elec_sector_path) == 0: run the python file?

Yes exactly, it executes the script and returns the exit code in 16 bits code. I explained this (with recent commit 3cee624) in a comment in the lines above if os.system("python " + self.elec_sector_path) == 0: .
But basically exit code 0 leads to 0 and exit code 1 leads to 256.

@MaGering
Copy link
Collaborator Author

@SabineHaas do you know why the Read the Docs build fails? :-/

@MaGering MaGering requested a review from SabineHaas April 13, 2021 09:21
@SabineHaas
Copy link
Collaborator

@SabineHaas do you know why the Read the Docs build fails? :-/

Seems like there's a problem with the installation of mock.. However, for #275 it works..
You could try to merge #275 to dev and merge changes into this PR.
If it still fails then we need to check further..

Copy link
Collaborator

@SabineHaas SabineHaas left a comment

Choose a reason for hiding this comment

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

Could you add an assertion statement behind the assertion e.g.
`, f"The example 'xy' exited with exit code {exit_code}." ?

Then everything looks good from my point of view.

tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
@MaGering
Copy link
Collaborator Author

Could you add an assertion statement behind the assertion e.g.
`, f"The example 'xy' exited with exit code {exit_code}." ?

Good point! Done with commit 5952083.

@MaGering MaGering merged commit e60daa4 into dev Apr 13, 2021
@MaGering MaGering deleted the feature/test_examples branch April 13, 2021 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants