diff --git a/.github/workflows/python-package.yml b/.github/workflows/test-with-tox.yml similarity index 78% rename from .github/workflows/python-package.yml rename to .github/workflows/test-with-tox.yml index 63a1767..3f05ccf 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/test-with-tox.yml @@ -10,14 +10,11 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["2.7", "3.10"] - + include: + - tox-envs: "sqla06-py27,sqla07-py27,sqla08-py27,sqla09-py27,sqlalchemy-py27" + - tox-envs: "sqlalchemy-py3" steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - name: Install dependencies run: | sudo apt-get -y install graphviz @@ -30,4 +27,4 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with tox run: | - tox + tox -v -e ${{ matrix.tox-envs }} -- -v --color=yes diff --git a/tests/test_schema_graph.py b/tests/test_schema_graph.py index a2f30e3..50b19fe 100644 --- a/tests/test_schema_graph.py +++ b/tests/test_schema_graph.py @@ -32,7 +32,7 @@ def test_no_args(): def test_empty_db(metadata): graph = sasd.create_schema_graph(metadata=metadata) assert isinstance(graph, pydot.Graph) - assert graph.create_plain() == 'graph 1 0 0\nstop\n' + assert graph.create_plain() == b'graph 1 0 0\nstop\n' def test_empty_table(metadata): @@ -40,8 +40,8 @@ def test_empty_table(metadata): 'foo', metadata, Column('id', types.Integer, primary_key=True)) result = plain_result(metadata=metadata) - assert result.keys() == ['1'] - assert result['1']['nodes'].keys() == ['foo'] + assert list(result.keys()) == ['1'] + assert list(result['1']['nodes'].keys()) == ['foo'] assert '- id : INTEGER' in result['1']['nodes']['foo'] @@ -51,8 +51,8 @@ def test_empty_table_with_key_suffix(metadata): Column('id', types.Integer, primary_key=True)) result = plain_result(metadata=metadata, show_column_keys=True) print(result) - assert result.keys() == ['1'] - assert result['1']['nodes'].keys() == ['foo'] + assert list(result.keys()) == ['1'] + assert list(result['1']['nodes'].keys()) == ['foo'] assert '- id(PK) : INTEGER' in result['1']['nodes']['foo'] @@ -64,7 +64,7 @@ def test_foreign_key(metadata): 'bar', metadata, Column('foo_id', types.Integer, ForeignKey(foo.c.id))) result = plain_result(metadata=metadata) - assert result.keys() == ['1'] + assert list(result.keys()) == ['1'] assert sorted(result['1']['nodes'].keys()) == ['bar', 'foo'] assert '- id : INTEGER' in result['1']['nodes']['foo'] assert '- foo_id : INTEGER' in result['1']['nodes']['bar'] @@ -80,7 +80,7 @@ def test_foreign_key_with_key_suffix(metadata): 'bar', metadata, Column('foo_id', types.Integer, ForeignKey(foo.c.id))) result = plain_result(metadata=metadata, show_column_keys=True) - assert result.keys() == ['1'] + assert list(result.keys()) == ['1'] assert sorted(result['1']['nodes'].keys()) == ['bar', 'foo'] assert '- id(PK) : INTEGER' in result['1']['nodes']['foo'] assert '- foo_id(FK) : INTEGER' in result['1']['nodes']['bar'] @@ -96,8 +96,8 @@ def test_table_filtering(metadata): 'bar', metadata, Column('foo_id', types.Integer, ForeignKey(foo.c.id))) result = plain_result(tables=[bar]) - assert result.keys() == ['1'] - assert result['1']['nodes'].keys() == ['bar'] + assert list(result.keys()) == ['1'] + assert list(result['1']['nodes'].keys()) == ['bar'] assert '- foo_id : INTEGER' in result['1']['nodes']['bar'] def test_table_rendering_without_schema(metadata): diff --git a/tests/test_uml_graph.py b/tests/test_uml_graph.py index b546624..ff73257 100644 --- a/tests/test_uml_graph.py +++ b/tests/test_uml_graph.py @@ -33,8 +33,8 @@ class Foo(Base): __tablename__ = 'foo' id = Column(types.Integer, primary_key=True) result = plain_result(mappers(Foo)) - assert result.keys() == ['1'] - assert result['1']['nodes'].keys() == ['Foo'] + assert list(result.keys()) == ['1'] + assert list(result['1']['nodes'].keys()) == ['Foo'] assert '+id : Integer' in result['1']['nodes']['Foo'] out, err = capsys.readouterr() assert out == u'' diff --git a/tests/utils.py b/tests/utils.py index 2f92d82..e716207 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -6,7 +6,8 @@ def parse_graph(graph): result = {} - sio = StringIO(graph.create_plain()) + graph_bytes = graph.create_plain() + sio = StringIO(graph_bytes.decode('utf-8')) graph = None for line in sio: line = line.strip() diff --git a/tox.ini b/tox.ini index 19db8af..bf29f6e 100644 --- a/tox.ini +++ b/tox.ini @@ -2,38 +2,30 @@ [testenv] commands = py.test --cov-report html --cov-report term --cov sqlalchemy_schemadisplay {posargs} - -[basedeps] deps = pytest pytest-cov [testenv:sqla06-py27] -basepython = python2.7 deps = - {[basedeps]deps} - sqlalchemy>0.6dev,<0.7dev + {[testenv]deps} + sqlalchemy==0.6.* [testenv:sqla07-py27] -basepython = python2.7 deps = - {[basedeps]deps} - sqlalchemy>0.7dev,<0.8dev + {[testenv]deps} + sqlalchemy==0.7.* [testenv:sqla08-py27] -basepython = python2.7 deps = - {[basedeps]deps} - sqlalchemy>0.8dev,<0.9dev + {[testenv]deps} + sqlalchemy==0.8.* [testenv:sqla09-py27] -basepython = python2.7 deps = - {[basedeps]deps} - sqlalchemy>0.9dev,<1.0dev + {[testenv]deps} + sqlalchemy==0.9.* [testenv:sqlalchemy-py27] -basepython = python2.7 -deps = - {[basedeps]deps} - sqlalchemy>0.9dev + +[testenv:sqlalchemy-py3]