Skip to content
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

Simplify test case creation #159

Merged
merged 2 commits into from
Mar 18, 2021
Merged

Simplify test case creation #159

merged 2 commits into from
Mar 18, 2021

Conversation

boyska
Copy link
Contributor

@boyska boyska commented Dec 28, 2020

While working on #158 I found it hard to generate the *.expected files. So I looked at test.py and modified it:

  • run_single_test has no forceargument anymore. I don't know if there was any case in which it was passed, indeed.
  • the equivalent of it is the environment variable FORCE_TESTDATA_CREATION ; set it to 1 and you are now in "force mode"
  • in force mode, only missing files are created. existing files are not overwritten

The workflow to create a test case is now much simpler:

  • create 1.config insde data/mysuite/
  • run env FORCE_TESTDATA_CREATION=1 python3 -m unittest. This will show you which files have been created, reporting them as errors.
  • Now you can run python3 -m unittest and it should pass
  • Of course, you need to check if you like the result
  • You might also need to anonymize Message-IDs

Hope you like it!

@boyska boyska marked this pull request as draft December 28, 2020 14:03
now you just put the rss file,the *.config files, and running
env FORCE_TESTDATA_CREATION=1 python3 -m unittest
will create your missing *.expected files

Of course you then need to check if you like it. You might also need to
"anonymize" message-IDs
@boyska boyska marked this pull request as ready for review December 28, 2020 14:04
Copy link
Member

@amiryal amiryal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also working on a patch and didn’t understand how to generate a new .expected file without modifying if force: to if True: temporarily. In the case of creating a new .expected, your proposed changes make it straightforward. It becomes trickier when you need to update an existing file, in which case you would have to delete the old one before running with FORCE_TESTEDATA_CREATION=1. This is good enough, though, so LGTM.

Copy link
Member

@Ekleog Ekleog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me too, thank you! I'll add a few lines to the readme after landing, so it's easier to know about this :)

test/test.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants