Repository: jklukas/sqlalchemy-views (language: python)

Issue:
test_basic_view fails
```
============================================================================================================================ test session starts =============================================================================================================================
platform darwin -- Python 3.7.6, pytest-5.4.3, py-1.8.2, pluggy-0.13.1
rootdir: /Users/wtregask/Documents/GitHub/sqlalchemy-views
collected 13 items                                                                                                                                                                                                                                                           

tests/test_views.py ..F.........                                                                                                                                                                                                                                       [ 92%]
README.rst .                                                                                                                                                                                                                                                           [100%]

================================================================================================================================== FAILURES ==================================================================================================================================
________________________________________________________________________________________ test_basic_view[myschema-schema_map2-CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1] _________________________________________________________________________________________

schema = 'myschema', schema_map = {'myschema': None}, expected_result = 'CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1'

    @pytest.mark.parametrize("schema,schema_map,expected_result", [
        (None, None, "CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1"),
        ('myschema', None, "CREATE VIEW myschema.myview AS SELECT myschema.t1.col1, myschema.t1.col2 FROM myschema.t1"),
        ('myschema', {'myschema': None}, "CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1"),
        ])
    def test_basic_view(schema, schema_map, expected_result):
        t1 = Table('t1', sa.MetaData(schema=schema),
                   sa.Column('col1', sa.Integer(), primary_key=True),
                   sa.Column('col2', sa.Integer()))
        selectable = sa.sql.select([t1])
        view = Table('myview', sa.MetaData(schema=schema))
        create_view = CreateView(view, selectable)
        actual = compile_query(create_view, schema_translate_map=schema_map)
>       assert clean(expected_result) == clean(actual)
E       AssertionError: assert 'CREATE VIEW ....col2 FROM t1' == 'CREATE VIEW ...M myschema.t1'
E         - CREATE VIEW myview AS SELECT myschema.t1.col1, myschema.t1.col2 FROM myschema.t1
E         ?                              ---------         ---------             ---------
E         + CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1

tests/test_views.py:38: AssertionError
========================================================================================================================== short test summary info ===========================================================================================================================
FAILED tests/test_views.py::test_basic_view[myschema-schema_map2-CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1] - AssertionError: assert 'CREATE VIEW ....col2 FROM t1' == 'CREATE VIEW ...M myschema.t1'
======================================================================================================================== 1 failed, 12 passed in 0.27s ========================================================================================================================
```

```
Package            Version
------------------ -------
attrs              19.3.0 
flake8             3.8.3  
importlib-metadata 1.6.1  
mccabe             0.6.1  
more-itertools     8.4.0  
packaging          20.4   
Paver              1.3.4  
pip                19.2.3 
pluggy             0.13.1 
py                 1.8.2  
pycodestyle        2.6.0  
pyflakes           2.2.0  
pyparsing          2.4.7  
pytest             5.4.3  
setuptools         41.2.0 
six                1.15.0 
SQLAlchemy         1.3.17 
wcwidth            0.2.5  
zipp               3.1.0 
```


Discussion / hints:
Looks like this is due to a change in behavior in more recent versions of SQLAlchemy. It's not clear to me the value of the test case that is failing here (involving schema_translate_map), so I am inclined to remove it. The tested behavior is related to query compilation internal to SQLAlchemy rather than the behavior of this view creation module.

Fix patch:
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 898ab65..28a1b06 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -15,7 +15,7 @@ pyflakes==0.7.3
 # Documentation
 Sphinx==1.2
 docutils==0.11
-Jinja2==2.7.1
+Jinja2==2.10.1
 MarkupSafe==0.18
 Pygments==1.6
 
diff --git a/requirements.txt b/requirements.txt
index c903928..479fe97 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,1 @@
-sqlalchemy>=1.0.0
-
-# Python 2.6 compatibility
-argparse==1.2.1
+sqlalchemy==1.3.17
diff --git a/tox.ini b/tox.ini
index 2a54994..741da35 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,7 @@
 # this directory.
 
 [tox]
-envlist = py26,py27,py33,py34,py35,pypy,docs
+envlist = py27,py34,py37,pypy,docs
 
 [testenv]
 deps =


Test patch:
diff --git a/tests/test_views.py b/tests/test_views.py
index 3fcf70d..aa2bffe 100644
--- a/tests/test_views.py
+++ b/tests/test_views.py
@@ -25,7 +25,6 @@ def compile_query(query, **kwargs):
 @pytest.mark.parametrize("schema,schema_map,expected_result", [
     (None, None, "CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1"),
     ('myschema', None, "CREATE VIEW myschema.myview AS SELECT myschema.t1.col1, myschema.t1.col2 FROM myschema.t1"),
-    ('myschema', {'myschema': None}, "CREATE VIEW myview AS SELECT t1.col1, t1.col2 FROM t1"),
     ])
 def test_basic_view(schema, schema_map, expected_result):
     t1 = Table('t1', sa.MetaData(schema=schema),