-
Notifications
You must be signed in to change notification settings - Fork 48
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
Set path for approved tests in code rather than config file #137
Comments
I think this can be acheived with specifying a namer, example:
the verify(result, options=Options().with_namer(namer)) Maybe a good start is to extend |
Thanks, I made it work! |
Cool, can you share your solution? |
Sure: # parameter is a string passed by pytest
# test_suite is a string passed by each test suite to create individual folders
# we want JSON output
options = approvaltests.Options({'extension_with_dot': '.json'})
# pass the parameter and set the output directory
namer = approvaltests.ScenarioNamer(approvaltests.get_default_namer(), parameter)
namer.base_namer.get_file_name()
namer.base_namer.config = {'subdirectory': os.path.join('approved_files', test_suite)}
namer.base_namer.config_loaded = True
options = options.with_namer(namer)
# json_object is built by the test and is a dict
# actual approval and passing our options
approvaltests.verify(data=json_object, encoding='utf-8', newline="\n", options=options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a test suite with over 64k tests from a single function in pytest. All approved tests are written to the same directory, which gets a bit crowded. I would like to create subdirectories to distribute the files.
Is there a way to set the directory of the approved tests in code? So far, I only found
approvaltests_config.json
, but this sets it for the whole test suite which is not sufficient for me.The text was updated successfully, but these errors were encountered: