-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
How to pytest raw_input calls #3504
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
Comments
Hi @ridhwaans, I think you want something like this (untested): from mymodule import validate
def test_validate_none():
assert validate(None) is None
def test_validate_empty():
assert validate('') is False
def test_validate_f(tmpdir):
assert validate(tmpdir.ensure('somefile')) FWIW a function returning This would naturally expand to a Testing the actual Hope this helps |
@nicoddemus yes the test cases are to cover the actual |
Yep that's the recommended way. You can also use I'm closing this for now but feel free to follow with further questions if you have any. |
In the end,
|
The solution and syntax for Python 3 can be found here |
Pytest newbie here
Want to make three test cases that take in
None
, nonexistant filenames and whitespace filenames forraw_input
inmain(prompt)
, and assert the print outputCode in question
Using: python
2.7
,pytest
latest versionThe text was updated successfully, but these errors were encountered: