Closed egork520 closed 1 year ago
Hey @comorado, I am not sure if it recommended to move directories during testing: I can imagine introducing a bug during tests that is caused by a previous test moving to a different directory.
In tests I've authored, I use __file__
to get an absolute path to fixtures, e.g. see tests/test_parsers/test_override.py
.
Some StackOverflow answers recommend creating functions pointing to paths and decorating them with @pytest.fixture
Hey @comorado, I am not sure if it recommended to move directories during testing: I can imagine introducing a bug during tests that is caused by a previous test moving to a different directory.
Good point @soldni, that's the reason why I had it in setUp method. setUp is run prior to running each individual test https://stackoverflow.com/questions/6854658/explain-the-setup-and-teardown-python-methods-used-in-test-cases
In tests I've authored, I use
__file__
to get an absolute path to fixtures, e.g. seetests/test_parsers/test_override.py
. I like your suggestion and instead of changing the directories I will create a class variable which points to the fixtures path.Some StackOverflow answers recommend creating functions pointing to paths and decorating them with
@pytest.fixture
A bit too fancy, thank you for the pointer :)
Hey @comorado, I am not sure if it recommended to move directories during testing: I can imagine introducing a bug during tests that is caused by a previous test moving to a different directory.
Good point @soldni, that's the reason why I had it in setUp method. setUp is run prior to running each individual test https://stackoverflow.com/questions/6854658/explain-the-setup-and-teardown-python-methods-used-in-test-cases
In tests I've authored, I use
__file__
to get an absolute path to fixtures, e.g. seetests/test_parsers/test_override.py
. I like your suggestion and instead of changing the directories I will create a class variable which points to the fixtures path. Some StackOverflow answers recommend creating functions pointing to paths and decorating them with@pytest.fixture
A bit too fancy, thank you for the pointer :)
@soldni I've pushed a commit where I am creating a path variable. Still doing it though in the setUp method. On the pytest run time each individual test receives it's version of the setUp variables. So for example if self.doc was modified in one test, another test is not going to see the modifications because it receives its version of the self.doc created by the setUp class.
Moving unite tests to the class. Locally pytest test would fail on this file