assert_attributes which checks attributes in an expected dictionary
assert_entries which asserts that all elements are contained as entries. This is required for the _InputOptionAccessor for example which contains the status of many flags like CONNECTION_REQUIRED.
I'm not 100% with using a helper function since dictionaries are harder to automatically refactor, but using a dictionary allows the possibility of reuse and can be more concise.
I also couldn't help myself and cleaned up a few things in the tests which were a bit strange.
I replaced many of the sys.path.append commands with .utils. This may cause a problem if you have not installed helics using pip install and are still trying to run tests from somewhere other than the root directory. Considering how annoying sys.path.append for any automatic tooling, I consider this specific use case somewhat irrelevant.
test_inits gets moved to .utils which is much more transparent and is not accessed by pytest
Changed the other functions in test_inits to be more pythonic.
Ran a python formatter on the tests. I didn't see any linting parameters, so I just used my own defaults.
Added a conftest.py to do helicsCloseLibrary. There are few functions which still call close library
to ensure that files are run. Doing this as an autouse fixture allows us to avoid segfaults on test failures, since it will run regardless of any asserts. TLDR: this clears up any segfaults on failures 🤞 .
Removed some uses of del. All that does it is signal the garbage collector, which already happens which it goes out of scope at the end of the function.
Replaces all repr testing with two functions:
CONNECTION_REQUIRED
.I'm not 100% with using a helper function since dictionaries are harder to automatically refactor, but using a dictionary allows the possibility of reuse and can be more concise.
I also couldn't help myself and cleaned up a few things in the tests which were a bit strange.
I replaced many of the sys.path.append commands with .utils. This may cause a problem if you have not installed helics using pip install and are still trying to run tests from somewhere other than the root directory. Considering how annoying sys.path.append for any automatic tooling, I consider this specific use case somewhat irrelevant.
del
. All that does it is signal the garbage collector, which already happens which it goes out of scope at the end of the function.