-
Notifications
You must be signed in to change notification settings - Fork 2
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
#124: Better error messages in case of missing parameters #148
Conversation
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | ||
"sub_dir, model_name", [ |
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.
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | |
"sub_dir, model_name", [ | |
@pytest.mark.parametrize(["description", "bucketfs_conn_name", "bucketfs_conn" , | |
"sub_dir", "model_name"], [ |
if parameter lists get long you can use either lists or sometimes you should also think about, if you create dataclass or so to wrap the parameters
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.
and another question is paramterize really necessary, because there is only one possible set
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.
That is true but it makes it more consistent with the other test
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.
When I look at the tests, you probably, can also simplify them, because they share a lot of code, almost everything except input_data construction and asserts, so maybe extract that.
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.
or alternatively, I sometimes have only one test and a parameter which specifies, if the test is expected to produce an error, and have two different asserts depending on that parameter
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | ||
"sub_dir, model_name", [ |
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.
and another question is paramterize really necessary, because there is only one possible set
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | ||
"sub_dir, model_name", [ |
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.
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | |
"sub_dir, model_name", [ | |
@pytest.mark.parametrize(["description", "bucketfs_conn_name", "bucketfs_conn" , | |
"sub_dir", "model_name"], [ |
if parameter lists get long you can use either lists or sometimes you should also think about, if you create dataclass or so to wrap the parameters
|
||
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | ||
"sub_dir, model_name", [ | ||
("all null", '', None, None, 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.
hm, it says all null, but bucketfs_Con is ''
suggestions from code review Co-authored-by: Torsten Kilias <[email protected]>
pattern = f"For each model model_name, bucketfs_conn and sub_dir need to be provided. Found model_name = " \ | ||
f"{model_name}, bucketfs_conn = .*, sub_dir = {sub_dir}." | ||
|
||
assert re.search(pattern, error_field) |
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.
I meant something, like that. It gives you a nicer diff
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | ||
"sub_dir, model_name", [ |
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.
When I look at the tests, you probably, can also simplify them, because they share a lot of code, almost everything except input_data construction and asserts, so maybe extract that.
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ," | ||
"sub_dir, model_name", [ |
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.
or alternatively, I sometimes have only one test and a parameter which specifies, if the test is expected to produce an error, and have two different asserts depending on that parameter
def __init__(self, some_sting): | ||
self._string = some_sting | ||
|
||
def __contains__(self, pattern): |
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 eq in the linked example has a reason. This gives you a good diff. You used it then
assert actual_value == regex_matcher("abc.*")
All Submissions:
[CodeBuild]
to the commit messageFixes Add better input validation for better error messages #124