|
|
|
|
|
by herpderperator
2067 days ago
|
|
RSpec is definitely better, but I've mimicked it this way with
pytest because I didn't like each Given/When decorator in pytest-bdd requiring a separate method to setup. It was way too verbose. I want to be able to quickly nest them, like in RSpec. So I do: TestSomeMethod:
TestWhenDateProvided:
def test_it_does_not_use_system_date(fixture, ...):
assert ...
TestWhenDateNotProvided:
def test_it_uses_system_date(fixture, ...):
assert ...
|
|
I’d use inherited test classes for this case, either sharing the setup in the parent and having each child define their own tests, or defining the test cases in the parent and overriding the setup in the child classes.
Seems like the latter might be hard in Rspec? But the former sounds more concise in the Rspec notation, I agree. I think Ruby’s anonymous blocks seem to be the differentiator in the toolset, I’ve not seen a Python DSL that’s as good in that regard.