|
29 | 29 | import uuid |
30 | 30 | import warnings |
31 | 31 |
|
32 | | -from shotgun_api3.lib import six |
33 | 32 | from shotgun_api3.lib.httplib2 import Http |
34 | 33 |
|
35 | 34 | import shotgun_api3 |
@@ -828,28 +827,24 @@ def test_summary_values(self): |
828 | 827 | sorted(result["groups"], key=lambda x: x["group_name"]), groups |
829 | 828 | ) |
830 | 829 |
|
831 | | - def test_ensure_ascii(self): |
832 | | - """test_ensure_ascii tests ensure_unicode flag.""" |
833 | | - sg_ascii = shotgun_api3.Shotgun( |
834 | | - self.config.server_url, ensure_ascii=True, **self.auth_args |
835 | | - ) |
| 830 | + def test_json_dumps_default_ensure_ascii_disabled(self): |
| 831 | + """Make sure SG'payload is using ensure_ascii for json dumps""" |
| 832 | + sg = shotgun_api3.Shotgun(self.config.server_url, **self.auth_args) |
836 | 833 |
|
837 | | - result = sg_ascii.find_one( |
838 | | - "Note", [["id", "is", self.note["id"]]], fields=["content"] |
839 | | - ) |
840 | | - if six.PY2: |
841 | | - # In Python3 there isn't a separate unicode type. |
842 | | - self.assertFalse(_has_unicode(result)) |
| 834 | + # Mock the _http_request method |
| 835 | + sg._orig_http_request = sg._http_request |
| 836 | + sg._http_request = unittest.mock.Mock(wraps=sg._orig_http_request) |
843 | 837 |
|
844 | | - def test_ensure_unicode(self): |
845 | | - """test_ensure_unicode tests ensure_unicode flag.""" |
846 | | - sg_unicode = shotgun_api3.Shotgun( |
847 | | - self.config.server_url, ensure_ascii=False, **self.auth_args |
| 838 | + sg.find_one( |
| 839 | + "Note", |
| 840 | + [["content", "is", "Noëlご"]], # Force a non-ascii character |
848 | 841 | ) |
849 | | - result = sg_unicode.find_one( |
850 | | - "Note", [["id", "is", self.note["id"]]], fields=["content"] |
| 842 | + |
| 843 | + sg._http_request.assert_called_once() |
| 844 | + self.assertIn( |
| 845 | + b"No\xc3\xabl\xe3\x81\x94", # utf-8 encoded version of Noëlご |
| 846 | + sg._http_request.call_args.args[2], # Get the body of the request |
851 | 847 | ) |
852 | | - self.assertTrue(_has_unicode(result)) |
853 | 848 |
|
854 | 849 | def test_work_schedule(self): |
855 | 850 | """test_work_schedule tests WorkDayRules api""" |
@@ -3409,15 +3404,6 @@ def test_import_httplib(self): |
3409 | 3404 | self.assertTrue(hasattr(socks, "HTTPError")) |
3410 | 3405 |
|
3411 | 3406 |
|
3412 | | -def _has_unicode(data): |
3413 | | - for k, v in data.items(): |
3414 | | - if isinstance(k, str): |
3415 | | - return True |
3416 | | - if isinstance(v, str): |
3417 | | - return True |
3418 | | - return False |
3419 | | - |
3420 | | - |
3421 | 3407 | def _get_path(url): |
3422 | 3408 | """Returns path component of a url without the sheme, host, query, anchor, or any other |
3423 | 3409 | additional elements. |
|
0 commit comments