cldf / csvw

CSV on the web
Apache License 2.0
36 stars 5 forks source link

Failing tests on Python 3.10 #58

Closed fabaff closed 2 years ago

fabaff commented 2 years ago

On Python 3.10 are some tests failing. They are passing on Python 3.9.

============================= test session starts ==============================
platform linux -- Python 3.10.1, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /build/source, configfile: setup.cfg, testpaths: tests
plugins: mock-3.6.1
collected 142 items / 1 deselected / 141 selected                              

tests/test_csv_escapechar.py ...X.XF                                     [  4%]
tests/test_datatypes.py ........                                         [ 10%]
tests/test_db.py ..............................................          [ 43%]
tests/test_dsv.py ......FFF.................                             [ 61%]
tests/test_dsv_dialect.py .                                              [ 62%]
tests/test_frictionless.py ...                                           [ 64%]
tests/test_metadata.py ...Fx.........................................    [ 97%]
tests/test_utils.py ....                                                 [100%]

=================================== FAILURES ===================================
__________________ test_escapequote_escapecharquotechar_final __________________

dialect = <class 'test_csv_escapechar.EscapeQuote'>

    def test_escapequote_escapecharquotechar_final(dialect=EscapeQuote):
        value = 'spam %s%s' % (dialect.escapechar, dialect.quotechar)
        out, cell = roundtrip(value, dialect)
>       assert out.strip() == '"spam //""'  # why does this not raise on reading?
E       assert 'spam ///"' == '"spam //""'
E         - "spam //""
E         ? -        -
E         + spam ///"
E         ?      +

tests/test_csv_escapechar.py:69: AssertionError
_____________________ test_roundtrip_escapechar[QUOTE_ALL] _____________________

tmp_path = PosixPath('/build/pytest-of-nixbld/pytest-0/test_roundtrip_escapechar_QUOT0')
quoting = 1, escapechar = '\\', row = ['\\spam', 'eggs']

    @pytest.mark.parametrize('quoting', [getattr(csv, q) for q in QUOTING], ids=QUOTING)
    def test_roundtrip_escapechar(tmp_path, quoting, escapechar='\\', row=['\\spam', 'eggs']):
        filename = tmp_path / 'spam.csv'
        kwargs = {'escapechar': escapechar, 'quoting': quoting}
        with UnicodeWriter(filename, **kwargs) as writer:
            writer.writerow(row)
        with UnicodeReader(filename, **kwargs) as reader:
            result = next(reader)
>       assert result == row
E       AssertionError: assert ['\\\\spam', 'eggs'] == ['\\spam', 'eggs']
E         At index 0 diff: '\\\\spam' != '\\spam'
E         Use -v to get the full diff

tests/test_dsv.py:83: AssertionError
___________________ test_roundtrip_escapechar[QUOTE_MINIMAL] ___________________

tmp_path = PosixPath('/build/pytest-of-nixbld/pytest-0/test_roundtrip_escapechar_QUOT1')
quoting = 0, escapechar = '\\', row = ['\\spam', 'eggs']

    @pytest.mark.parametrize('quoting', [getattr(csv, q) for q in QUOTING], ids=QUOTING)
    def test_roundtrip_escapechar(tmp_path, quoting, escapechar='\\', row=['\\spam', 'eggs']):
        filename = tmp_path / 'spam.csv'
        kwargs = {'escapechar': escapechar, 'quoting': quoting}
        with UnicodeWriter(filename, **kwargs) as writer:
            writer.writerow(row)
        with UnicodeReader(filename, **kwargs) as reader:
            result = next(reader)
>       assert result == row
E       AssertionError: assert ['\\\\spam', 'eggs'] == ['\\spam', 'eggs']
E         At index 0 diff: '\\\\spam' != '\\spam'
E         Use -v to get the full diff

tests/test_dsv.py:83: AssertionError
_________________ test_roundtrip_escapechar[QUOTE_NONNUMERIC] __________________

tmp_path = PosixPath('/build/pytest-of-nixbld/pytest-0/test_roundtrip_escapechar_QUOT2')
quoting = 2, escapechar = '\\', row = ['\\spam', 'eggs']

    @pytest.mark.parametrize('quoting', [getattr(csv, q) for q in QUOTING], ids=QUOTING)
    def test_roundtrip_escapechar(tmp_path, quoting, escapechar='\\', row=['\\spam', 'eggs']):
        filename = tmp_path / 'spam.csv'
        kwargs = {'escapechar': escapechar, 'quoting': quoting}
        with UnicodeWriter(filename, **kwargs) as writer:
            writer.writerow(row)
        with UnicodeReader(filename, **kwargs) as reader:
            result = next(reader)
>       assert result == row
E       AssertionError: assert ['\\\\spam', 'eggs'] == ['\\spam', 'eggs']
E         At index 0 diff: '\\\\spam' != '\\spam'
E         Use -v to get the full diff

tests/test_dsv.py:83: AssertionError
_________________________ TestDialect.test_doubleQuote _________________________

self = <test_metadata.TestDialect object at 0x7ffff5aecd30>
tmp_path = PosixPath('/build/pytest-of-nixbld/pytest-0/test_doubleQuote0')

    def test_doubleQuote(self, tmp_path):
        fpath = tmp_path / 'test'
        t = csvw.Table.fromvalue({
            "url": fpath,
            "dialect": {"doubleQuote": True},
            "tableSchema": {
                "columns": [
                    {"name": "col1", "datatype": "string"},
                    {"name": "col2", "datatype": "string"},
                ]
            }
        })
        value = r'"a\\b\c\"d'
        c, res = self._roundtrip(t, fpath, {"col1": "", "col2": value})
        assert r'""a\\b\c\""d' in c
        assert res[0]['col2'] == value

        t.dialect.doubleQuote = False
        c, res = self._roundtrip(t, fpath, {"col1": "", "col2": value})
>       assert r'\"a\\\\b\\c\\\"d' in c
E       assert '\\"a\\\\\\\\b\\\\c\\\\\\"d' in 'col1,col2\n,\\"a\\\\\\\\\\\\\\\\b\\\\\\\\c\\\\\\\\\\"d\n'

tests/test_metadata.py:81: AssertionError
=========================== short test summary info ============================
FAILED tests/test_csv_escapechar.py::test_escapequote_escapecharquotechar_final
FAILED tests/test_dsv.py::test_roundtrip_escapechar[QUOTE_ALL] - AssertionErr...
FAILED tests/test_dsv.py::test_roundtrip_escapechar[QUOTE_MINIMAL] - Assertio...
FAILED tests/test_dsv.py::test_roundtrip_escapechar[QUOTE_NONNUMERIC] - Asser...
FAILED tests/test_metadata.py::TestDialect::test_doubleQuote - assert '\\"a\\...
====== 5 failed, 133 passed, 1 deselected, 1 xfailed, 2 xpassed in 0.64s =======
xflr6 commented 2 years ago

Possibly related to https://bugs.python.org/issue44861

xrotwang commented 2 years ago

Hm. That's unfortunate. And it doesn't seem like anything is going to change upstream. So do we just pass on the inconsistent behaviour to our users - i.e. mark the text as xfail on py3.10?