diff options
author | Federico Caselli <cfederico87@gmail.com> | 2022-11-03 20:52:21 +0100 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2022-11-16 23:03:04 +0100 |
commit | 4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66 (patch) | |
tree | 4970cff3f78489a4a0066cd27fd4bae682402957 /test/base/test_utils.py | |
parent | 3fc6c40ea77c971d3067dab0fdf57a5b5313b69b (diff) | |
download | sqlalchemy-4eb4ceca36c7ce931ea65ac06d6ed08bf459fc66.tar.gz |
Try running pyupgrade on the code
command run is "pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format <files...>"
pyupgrade will change assert_ to assertTrue. That was reverted since assertTrue does not
exists in sqlalchemy fixtures
Change-Id: Ie1ed2675c7b11d893d78e028aad0d1576baebb55
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 349ee8c05..b979d43bc 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -1,5 +1,3 @@ -#! coding: utf-8 - import copy import inspect from pathlib import Path @@ -543,7 +541,7 @@ class ToListTest(fixtures.TestBase): eq_(util.to_list("xyz"), ["xyz"]) def test_from_set(self): - spec = util.to_list(set([1, 2, 3])) + spec = util.to_list({1, 2, 3}) assert isinstance(spec, list) eq_(sorted(spec), [1, 2, 3]) @@ -567,7 +565,7 @@ class ToListTest(fixtures.TestBase): class ColumnCollectionCommon(testing.AssertsCompiledSQL): def _assert_collection_integrity(self, coll): - eq_(coll._colset, set(c for k, c, _ in coll._collection)) + eq_(coll._colset, {c for k, c, _ in coll._collection}) d = {} for k, col, _ in coll._collection: d.setdefault(k, (k, col)) @@ -1964,7 +1962,7 @@ class IdentitySetTest(fixtures.TestBase): assert True try: - s = set([o1, o2]) + s = {o1, o2} s |= ids assert False except TypeError: @@ -2019,7 +2017,7 @@ class OrderedIdentitySetTest(fixtures.TestBase): class DictlikeIteritemsTest(fixtures.TestBase): - baseline = set([("a", 1), ("b", 2), ("c", 3)]) + baseline = {("a", 1), ("b", 2), ("c", 3)} def _ok(self, instance): iterator = util.dictlike_iteritems(instance) @@ -2966,7 +2964,7 @@ class GenericReprTest(fixtures.TestBase): self.e = e self.f = f self.g = g - super(Bar, self).__init__(**kw) + super().__init__(**kw) eq_( util.generic_repr( @@ -2989,7 +2987,7 @@ class GenericReprTest(fixtures.TestBase): class Bar(Foo): def __init__(self, b=3, c=4, **kw): self.c = c - super(Bar, self).__init__(b=b, **kw) + super().__init__(b=b, **kw) eq_( util.generic_repr(Bar(a="a", b="b", c="c"), to_inspect=[Bar, Foo]), @@ -3125,7 +3123,7 @@ class AsInterfaceTest(fixtures.TestBase): def assertAdapted(obj, *methods): assert isinstance(obj, type) - found = set([m for m in dir(obj) if not m.startswith("_")]) + found = {m for m in dir(obj) if not m.startswith("_")} for method in methods: assert method in found found.remove(method) @@ -3163,7 +3161,7 @@ class AsInterfaceTest(fixtures.TestBase): class TestClassHierarchy(fixtures.TestBase): def test_object(self): - eq_(set(util.class_hierarchy(object)), set((object,))) + eq_(set(util.class_hierarchy(object)), {object}) def test_single(self): class A: @@ -3172,14 +3170,14 @@ class TestClassHierarchy(fixtures.TestBase): class B: pass - eq_(set(util.class_hierarchy(A)), set((A, object))) - eq_(set(util.class_hierarchy(B)), set((B, object))) + eq_(set(util.class_hierarchy(A)), {A, object}) + eq_(set(util.class_hierarchy(B)), {B, object}) class C(A, B): pass - eq_(set(util.class_hierarchy(A)), set((A, B, C, object))) - eq_(set(util.class_hierarchy(B)), set((A, B, C, object))) + eq_(set(util.class_hierarchy(A)), {A, B, C, object}) + eq_(set(util.class_hierarchy(B)), {A, B, C, object}) class TestClassProperty(fixtures.TestBase): @@ -3190,7 +3188,7 @@ class TestClassProperty(fixtures.TestBase): class B(A): @classproperty def something(cls): - d = dict(super(B, cls).something) + d = dict(super().something) d.update({"bazz": 2}) return d @@ -3319,7 +3317,7 @@ class BackslashReplaceTest(fixtures.TestBase): def test_utf8_to_utf8(self): eq_( compat.decode_backslashreplace( - "some message méil".encode("utf-8"), "utf-8" + "some message méil".encode(), "utf-8" ), "some message méil", ) |