-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add test helpers, rewrite integration tests #100
Conversation
Codecov Report
@@ Coverage Diff @@
## master #100 +/- ##
==========================================
- Coverage 95.37% 89.44% -5.93%
==========================================
Files 7 9 +2
Lines 584 597 +13
==========================================
- Hits 557 534 -23
- Misses 27 63 +36
Continue to review full report at Codecov.
|
0bd9ccd
to
d04ac50
Compare
tests/test_integration.py
Outdated
assert result.stderr == "" | ||
assert result.returncode == 0 | ||
|
||
result = run("riot list", cwd=tmp_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should get the same for riot run
and riot generate
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, are you suggesting that we should also check those here? Would be an easy parametrization
test .* 'pkg1==1.0' | ||
test .* 'pkg1==2.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should know this exact string no? since this is the python version and we know the currently running version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasoning here is that the interpreter could be platform dependent. Right now it'd be fine because the output there would probably just be Interpreter(_hint="3")
but in #137 we'd also have the path to the interpreter.
What we can do is at least match on Interpreter(.*)
or similar. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes me wonder if we need better output here than what we have now repr(Interpreter)
could make this more of a consistent format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I am suggesting a specific change right now, just talking out loud.
Reduces the boilerplate of having to specify cwd every time when commands are 99% of the time run in the tmp_path.
Protocol was only introduced in Python 3.8. typing_extensions makes it available for older Pythons.
test .* 'pkg1==1.0' | ||
test .* 'pkg1==2.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes me wonder if we need better output here than what we have now repr(Interpreter)
could make this more of a consistent format
test .* 'pkg1==1.0' | ||
test .* 'pkg1==2.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I am suggesting a specific change right now, just talking out loud.
assert result.returncode == 1 | ||
|
||
|
||
def test_bad_interpreter(tmp_path: pathlib.Path, tmp_run: _T_TmpRun) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_bad_interpreter(tmp_path: pathlib.Path, tmp_run: _T_TmpRun) -> None: | |
@with_riotfile( | |
""" | |
from riot import Venv | |
venv = Venv( | |
... | |
) | |
""" | |
, filename="bad-riotfile.py", # Obviously the default is `riotfile.py` | |
) | |
def test_bad_interpreter(riotfile: pathlib.Path, tmp_run: _T_TmpRun) -> None: |
def test_bad_interpreter(tmp_path: pathlib.Path, tmp_run: _T_TmpRun) -> None: | |
@with_riotfile_fixture("some-file-in-data-dir.py) | |
def test_bad_interpreter(riotfile: pathlib.Path, tmp_run: _T_TmpRun) -> None: |
Just writing something down as a trial to see how it felt, not suggesting a change here.
Co-authored-by: Brett Langdon <me@brett.is>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Adding manual merge in case we want another review.
Feel free to remove it if everyone's happy.
Add test helpers to do proper input/output testing.