diff options
author | Miroslav Šedivý <6774676+eumiro@users.noreply.github.com> | 2021-02-12 20:34:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-12 21:34:56 +0200 |
commit | 762fb4b8da98fdf6792e6c5586060ed37224f894 (patch) | |
tree | dca17819ff2a516988e2f74691dcef0554637464 /tests/test_pgspecial.py | |
parent | 87ffae295edf4fb2a9c33c552b12f09921def29f (diff) |
Modernize code to Python 3.6+ (#1229)
1. `class A(object)` can be written as `class A:`
2. replace `dict([…])` and `set([…])` with `{…}`
3. use f-strings or compact `.format`
4. use `yield from` instead of `yield` in a `for` loop
5. import `mock` from `unittest`
6. expect `OSError` instead of `IOError` or `select` error
7. use Python3 defaults for file reading or `super()`
8. remove redundant parenthesis (keep those in tuples though)
9. shorten set intersection instead of creating lists
10. backslashes in strings do not have to be escaped if prepended with `r`
Diffstat (limited to 'tests/test_pgspecial.py')
-rw-r--r-- | tests/test_pgspecial.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/test_pgspecial.py b/tests/test_pgspecial.py index eaeaf12f..cd99e321 100644 --- a/tests/test_pgspecial.py +++ b/tests/test_pgspecial.py @@ -13,12 +13,12 @@ from pgcli.packages.sqlcompletion import ( def test_slash_suggests_special(): suggestions = suggest_type("\\", "\\") - assert set(suggestions) == set([Special()]) + assert set(suggestions) == {Special()} def test_slash_d_suggests_special(): suggestions = suggest_type("\\d", "\\d") - assert set(suggestions) == set([Special()]) + assert set(suggestions) == {Special()} def test_dn_suggests_schemata(): @@ -30,24 +30,24 @@ def test_dn_suggests_schemata(): def test_d_suggests_tables_views_and_schemas(): - suggestions = suggest_type("\d ", "\d ") - assert set(suggestions) == set([Schema(), Table(schema=None), View(schema=None)]) + suggestions = suggest_type(r"\d ", r"\d ") + assert set(suggestions) == {Schema(), Table(schema=None), View(schema=None)} - suggestions = suggest_type("\d xxx", "\d xxx") - assert set(suggestions) == set([Schema(), Table(schema=None), View(schema=None)]) + suggestions = suggest_type(r"\d xxx", r"\d xxx") + assert set(suggestions) == {Schema(), Table(schema=None), View(schema=None)} def test_d_dot_suggests_schema_qualified_tables_or_views(): - suggestions = suggest_type("\d myschema.", "\d myschema.") - assert set(suggestions) == set([Table(schema="myschema"), View(schema="myschema")]) + suggestions = suggest_type(r"\d myschema.", r"\d myschema.") + assert set(suggestions) == {Table(schema="myschema"), View(schema="myschema")} - suggestions = suggest_type("\d myschema.xxx", "\d myschema.xxx") - assert set(suggestions) == set([Table(schema="myschema"), View(schema="myschema")]) + suggestions = suggest_type(r"\d myschema.xxx", r"\d myschema.xxx") + assert set(suggestions) == {Table(schema="myschema"), View(schema="myschema")} def test_df_suggests_schema_or_function(): suggestions = suggest_type("\\df xxx", "\\df xxx") - assert set(suggestions) == set([Function(schema=None, usage="special"), Schema()]) + assert set(suggestions) == {Function(schema=None, usage="special"), Schema()} suggestions = suggest_type("\\df myschema.xxx", "\\df myschema.xxx") assert suggestions == (Function(schema="myschema", usage="special"),) @@ -63,7 +63,7 @@ def test_leading_whitespace_ok(): def test_dT_suggests_schema_or_datatypes(): text = "\\dT " suggestions = suggest_type(text, text) - assert set(suggestions) == set([Schema(), Datatype(schema=None)]) + assert set(suggestions) == {Schema(), Datatype(schema=None)} def test_schema_qualified_dT_suggests_datatypes(): |