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
Added ability to set custom currency choices via CURRENCY_CHOICES
settings option. Closes #211
#271
Added ability to set custom currency choices via CURRENCY_CHOICES
settings option. Closes #211
#271
Conversation
… settings option. Closes #211
Codecov Report
@@ Coverage Diff @@
## master #271 +/- ##
==========================================
+ Coverage 93.99% 94.31% +0.32%
==========================================
Files 17 17
Lines 783 792 +9
Branches 150 151 +1
==========================================
+ Hits 736 747 +11
+ Misses 34 32 -2
Partials 13 13
Continue to review full report at Codecov.
|
…ork. #218 (#270) * Refactor migrations tests, add tests for Django 1.7+ migration framework. #218 * Fix module check * Simplify * Add some shims * Fix * Fix bytecode & migrations check * Fix * Cleanup, run less things in subprocesses * Add stdout checks for migrations * More checks * Fix lines * Simplify
@Stranger6667 I'm unfortunately lacking time and bandwidth for the next 2-3 weeks :/ will put it on my getting-back TODO - if you can wait.. |
@benjaoming no problem :) |
Solid work! :) |
tests/test_settings.py
Outdated
'--cov', 'djmoney', | ||
'--cov-config', 'coveragerc.ini', | ||
) | ||
result.stdout.fnmatch_lines(lines) |
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.
Does this run all tests again but with different settings?
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.
It works in the following way:
- We create a new settings file in temp directory
- We run pytest in subprocess to avoid all possible module reloading issues, which will be the same if we will run it against the new project
- test is performed in a regular way
- we compare expected output in the main process
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.
Still a couple of questions :)
- Do you mean all tests?
- Why is module reloading a requirement? Shouldn't such be done explicitly?
- All tests are subject to "what if modules are loaded in a different order, let's load everything again in an isolated environment"
Can this be used?
https://docs.djangoproject.com/en/dev/topics/testing/tools/#overriding-settings
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.
- No, it runs only tests defined in the temp directory, in these cases it is 1 subprocess test per test method in the class
- If we load
djmoney.settings
in first test once it will load Django's settings. In second test if we need to test another combination of settings we will need to change them in settings.py, removedjmoney/settings.pyc
and loaddjmoney.settings
again to get new values and cover all logic branches indjmoney.settings
. I'm not sure if we can do it in the same way on all Django/Python combinations that we support. So, this solution is rough but isolated :) - Almost, in this case the most problematic thing is that avoiding module reloading and caching issues seems to me core complicated than running every test in the isolated environment.
I'm not sure about https://docs.djangoproject.com/en/dev/topics/testing/tools/#overriding-settings, I'll try it :)
Probably running python with -B option could help. I will try to simplify tests :)
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.
Ah, I see what you mean after reading this in the docs:
Finally, avoid aliasing your settings as module-level constants as override_settings() won’t work on such values since they are only evaluated the first time the module is imported.
Maybe we can use override_settings
+ reload(djmoney.settings)
?
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.
Yes! It works for Django 1.10 and Python 2.7. I'll check the rest and push changes
Thank you for the review :)
The initial implementation is really an overkill
tests/test_settings.py
Outdated
CURRENCY_CHOICES = [('USD', 'USD $'), ('EUR', 'EUR €')] | ||
|
||
SECRET_KEY = 'foobar' | ||
''') |
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.
This is tooooooo weird IMO :)
As was requested in #211
What do you think about this feature?