-
Notifications
You must be signed in to change notification settings - Fork 295
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
Deprecate generic.checksums.luhn and ean #370
Changes from 1 commit
5392673
1bc2c91
92807ce
66df978
a1a6db0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,11 @@ def find_package_data(where='.', package='', | |
author_email='[email protected]', | ||
packages=find_packages(exclude=['tests', 'tests.*']), | ||
package_data=find_package_data(), | ||
install_requires=['django>=1.11'], | ||
install_requires=[ | ||
'django>=1.11', | ||
'python-stdnum>=1.0', | ||
'mock>=2.0;python_version<"3.0"', | ||
], | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'Environment :: Web Environment', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import warnings | ||
|
||
from django.test import SimpleTestCase | ||
|
||
from localflavor.deprecation import RemovedInLocalflavor30Warning | ||
from localflavor.generic.checksums import luhn | ||
|
||
try: | ||
from unittest.mock import patch | ||
except ImportError: | ||
from mock import patch | ||
|
||
|
||
class DeprecatedFieldsTests(SimpleTestCase): | ||
@patch('localflavor.generic.checksums.stdnum_luhn') | ||
def test_luhn_deprecated(self, stdnum_luhn): | ||
with warnings.catch_warnings(record=True) as recorded: | ||
warnings.simplefilter('always') | ||
luhn('1234') | ||
|
||
self.assertTrue(all(w.category is RemovedInLocalflavor30Warning for w in recorded)) | ||
stdnum_luhn.asert_called_once_with('1234') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange that the tests don't fail with the typ0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's mock - it silently allows undefined methods to be called without raising an error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way - nice catch! :-) |
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.
Not sure, what is the role of patch here?
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.
Oh, for the assertion below? All that just for testing a deprecation. I wouldn't have moaned if you omitted 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.
I agree it's a bit pedantic - thanks for pointing this out. Removing these tests also means I can remove the additional requirement for mock on Python 2 which simplifies things a bit.