chevah / compat

Chevah OS Compatibility Layer
Other
4 stars 1 forks source link

[#5687] assertEqual checks Unicode vs. strings in collections #114

Closed danuker closed 3 years ago

danuker commented 3 years ago

Scope

ChevahTestCase.assertEqual now goes inside dicts, lists, tuples, and sets to differentiate Unicode vs. raw string objects.

Changes

Added behavior to chevah/compat/testing/testcase.py.

Overrode unittest methods named assertSequenceEqual, assertSetEqual, and assertDictEqual.

As a drive-by found a bug where temp_segments would return raw strings and not Unicode ones.

How to try and test the changes

reviewers: @adiroiban

Use assertEquals in various ways.

This PR should have a counterpart in chevah/server before merging, which fixes the tests broken (or bugs discovered) by the compat changes.

codecov[bot] commented 3 years ago

Codecov Report

Merging #114 (c223ebd) into master (0755b22) will increase coverage by 0.08%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   87.57%   87.65%   +0.08%     
==========================================
  Files          58       58              
  Lines        7887     7941      +54     
  Branches      652      653       +1     
==========================================
+ Hits         6907     6961      +54     
  Misses        767      767              
  Partials      213      213              
Impacted Files Coverage Δ
chevah/compat/nt_filesystem.py 90.84% <100.00%> (+0.02%) :arrow_up:
chevah/compat/nt_service.py 74.19% <100.00%> (ø)
chevah/compat/posix_filesystem.py 92.56% <100.00%> (ø)
chevah/compat/testing/testcase.py 79.93% <100.00%> (+0.60%) :arrow_up:
...evah/compat/tests/normal/testing/test_assertion.py 100.00% <100.00%> (ø)
danuker commented 3 years ago

I think this is ready for review. Should I open another ticket for the changes on chevah/server?

Edit: there were 230 test failures for server with this change. I will start working on Azure until you prioritize.

======================================================================
FAIL: test_init_no_external_configuration - normal.identity.test_model:TestExternalAccountConfigurationAbstract.test_init_no_external_configuration
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dan/Documents/Work/ProAtria/server/build-server/lib/python2.7/site-packages/chevah/compat/testing/nose_test_timer.py", line 89, in __call__
    self.__target()
  File "/home/dan/Documents/Work/ProAtria/server/chevah/server/tests/normal/identity/test_model.py", line 200, in test_init_no_external_configuration
    (CONFIGURATION_INHERIT[0],), config.required_credentials)
AssertionError: First is unicode while second is <type 'str'> for "inherit".

======================================================================
FAIL: test_default_IPv4Address - normal.json.test_codex:TestChevahJSONEncoder.test_default_IPv4Address
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dan/Documents/Work/ProAtria/server/build-server/lib/python2.7/site-packages/chevah/compat/testing/nose_test_timer.py", line 89, in __call__
    self.__target()
  File "/home/dan/Documents/Work/ProAtria/server/chevah/server/tests/normal/json/test_codex.py", line 57, in test_default_IPv4Address
    self.assertEqual(expected_data, result)
AssertionError: First is unicode while second is <type 'str'> for "127.0.0.1".

======================================================================
FAIL: test_default_IPv6Address - normal.json.test_codex:TestChevahJSONEncoder.test_default_IPv6Address
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dan/Documents/Work/ProAtria/server/build-server/lib/python2.7/site-packages/chevah/compat/testing/nose_test_timer.py", line 89, in __call__
    self.__target()
  File "/home/dan/Documents/Work/ProAtria/server/chevah/server/tests/normal/json/test_codex.py", line 73, in test_default_IPv6Address
    self.assertEqual(expected_data, result)
AssertionError: First is unicode while second is <type 'str'> for "2001:0db8:85a3:0000:0000:8a2e:0370:7334".

needs-review

danuker commented 3 years ago

The windows tests failed. Taking it back; sorry for the noise. needs-changes

danuker commented 3 years ago

Done fixing the tests. Changes are ready for review again. needs-review

danuker commented 3 years ago

Released as chevah_compat-0.62.0-py2-none-any.whl.

Created ticket for server upgrade: https://trac.chevah.com/ticket/5688