diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-07-29 14:52:25 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-07-29 14:52:25 +0200 |
commit | 3a029a8cca4887c4ab61e90de8450b536a6cbb0c (patch) | |
tree | e4a6f9555e00f211592f204a0d0f422eecc65fbd | |
parent | f9b50b606fe3f12b09dd36cb999238bf440d0cd1 (diff) | |
download | ruamel.yaml-3a029a8cca4887c4ab61e90de8450b536a6cbb0c.tar.gz |
added captured DeprecationWarning test0.15.46
-rw-r--r-- | CHANGES | 27 | ||||
-rw-r--r-- | README.rst | 15 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _test/roundtrip.py | 28 | ||||
-rw-r--r-- | _test/test_deprecation.py | 12 | ||||
-rw-r--r-- | _test/test_yamlobject.py | 40 | ||||
-rw-r--r-- | tox.ini | 21 |
7 files changed, 106 insertions, 41 deletions
@@ -1,3 +1,30 @@ +[0, 15, 46]: 2018-07-29 + - fixed DeprecationWarning for importing from ``collections`` on 3.7 + (issue 210, reported by `Reinoud Elhorst + <https://bitbucket.org/reinhrst/>`__). It was `difficult to find + why tox/pytest did not report + <https://stackoverflow.com/q/51573204/1307905>`__ and as time + consuming to actually `fix + <https://stackoverflow.com/a/51573205/1307905>`__ the tests. + +[0, 15, 46]: 2018-07-29 + - fixed DeprecationWarning for importing from ``collections`` on 3.7 + (issue 210, reported by `Reinoud Elhorst + <https://bitbucket.org/reinhrst/>`__). It was `difficult to find + why tox/pytest did not report + <https://stackoverflow.com/q/51573204/1307905>`__ and as time + consuming to actually `fix + <https://stackoverflow.com/a/51573205/1307905>`__ the tests. + +[0, 15, 45]: 2018-07-29 + - fixed DeprecationWarning for importing from ``collections`` on 3.7 + (issue 210, reported by `Reinoud Elhorst + <https://bitbucket.org/reinhrst/>`__). It was `difficult to find + why tox/pytest did not report + <https://stackoverflow.com/q/51573204/1307905>`__ and as time + consuming to actually `fix + <https://stackoverflow.com/a/51573205/1307905>`__ the tests. + [0, 15, 45]: 2018-07-26 - After adding failing test for ``YAML.load_all(Path())``, remove StopIteration (PR provided by `Zachary Buhman <https://bitbucket.org/buhman/>`__, @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.15.45 -:updated: 2018-07-26 +:version: 0.15.46 +:updated: 2018-07-29 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/ :pypi: https://pypi.org/project/ruamel.yaml/ @@ -42,6 +42,15 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) +0.15.46 (2018-07-29): + - fixed DeprecationWarning for importing from ``collections`` on 3.7 + (issue 210, reported by `Reinoud Elhorst + <https://bitbucket.org/reinhrst/>`__). It was `difficult to find + why tox/pytest did not report + <https://stackoverflow.com/q/51573204/1307905>`__ and as time + consuming to actually `fix + <https://stackoverflow.com/a/51573205/1307905>`__ the tests. + 0.15.45 (2018-07-26): - After adding failing test for ``YAML.load_all(Path())``, remove StopIteration (PR provided by `Zachary Buhman <https://bitbucket.org/buhman/>`__, @@ -65,7 +74,7 @@ ChangeLog - fix regression showing only on narrow Python 2.7 (py27mu) builds (with help from `Marcel Bargull <https://bitbucket.org/mbargull/>`__ and - `Colm O'Connor <>`__). + `Colm O'Connor <https://bitbucket.org/colmoconnorgithub/>`__). - run pre-commit ``tox`` on Python 2.7 wide and narrow, as well as 3.4/3.5/3.6/3.7/pypy diff --git a/__init__.py b/__init__.py index 16bce19..7b7ca99 100644 --- a/__init__.py +++ b/__init__.py @@ -7,8 +7,8 @@ if False: # MYPY _package_data = dict( full_package_name='ruamel.yaml', - version_info=(0, 15, 45), - __version__='0.15.45', + version_info=(0, 15, 46), + __version__='0.15.46', author='Anthon van der Neut', author_email='a.van.der.neut@ruamel.eu', description='ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order', # NOQA diff --git a/_test/roundtrip.py b/_test/roundtrip.py index 3a842a9..8548969 100644 --- a/_test/roundtrip.py +++ b/_test/roundtrip.py @@ -7,6 +7,9 @@ helper routines for testing round trip of commented YAML data """ import sys import textwrap +from ruamel.std.pathlib import Path + +enforce = object() def dedent(data): @@ -168,3 +171,28 @@ def YAML(**kw): assert res == outp return MyYAML(**kw) + + +def save_and_run(program, base_dir=None, file_name=None): + """ + safe and run a python program, thereby circumventing any restrictions on module level + imports + """ + from subprocess import check_output, STDOUT, CalledProcessError + + if not hasattr(base_dir, 'hash'): + base_dir = Path(str(base_dir)) + if file_name is None: + file_name = 'safe_and_run_tmp.py' + file_name = base_dir / file_name + file_name.write_text(dedent(program)) + + try: + cmd = [sys.executable, str(file_name)] + print('running:', *cmd) + check_output(cmd, stderr=STDOUT, universal_newlines=True) + except CalledProcessError as exception: + print("##### Running '{} {}' FAILED #####".format(sys.exeutable, file_name)) + print(exception.output) + return exception.returncode + return 0 diff --git a/_test/test_deprecation.py b/_test/test_deprecation.py new file mode 100644 index 0000000..f1a5419 --- /dev/null +++ b/_test/test_deprecation.py @@ -0,0 +1,12 @@ +# coding: utf-8 + +from __future__ import print_function + +import sys +import pytest # NOQA + + +@pytest.mark.skipif(sys.version_info < (3, 7), reason="collections not available?") +def test_collections_deprecation(): + with pytest.warns(DeprecationWarning): + from collections import Hashable # NOQA diff --git a/_test/test_yamlobject.py b/_test/test_yamlobject.py index ee39c89..4147bc3 100644 --- a/_test/test_yamlobject.py +++ b/_test/test_yamlobject.py @@ -1,12 +1,16 @@ # coding: utf-8 +from __future__ import print_function + import pytest # NOQA -from roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA +from roundtrip import save_and_run # NOQA -def register_monster(): - import ruamel.yaml # NOQA +def test_monster(tmpdir): + program_src = u'''\ + import ruamel.yaml + from textwrap import dedent class Monster(ruamel.yaml.YAMLObject): yaml_tag = u'!Monster' @@ -21,22 +25,20 @@ def register_monster(): return "%s(name=%r, hp=%r, ac=%r, attacks=%r)" % ( self.__class__.__name__, self.name, self.hp, self.ac, self.attacks) - -def test_monster(): - import ruamel.yaml # NOQA - register_monster() - data = ruamel.yaml.load(dedent("""\ - --- !Monster - name: Cave spider - hp: [2,6] # 2d6 - ac: 16 - attacks: [BITE, HURT] + data = ruamel.yaml.load(dedent("""\\ + --- !Monster + name: Cave spider + hp: [2,6] # 2d6 + ac: 16 + attacks: [BITE, HURT] """), Loader=ruamel.yaml.Loader) # normal dump, keys will be sorted - assert ruamel.yaml.dump(data) == dedent("""\ - !Monster - ac: 16 - attacks: [BITE, HURT] - hp: [2, 6] - name: Cave spider + assert ruamel.yaml.dump(data) == dedent("""\\ + !Monster + ac: 16 + attacks: [BITE, HURT] + hp: [2, 6] + name: Cave spider """) + ''' + assert save_and_run(program_src, tmpdir) == 0 @@ -1,10 +1,10 @@ [tox] -toworkdir = /data1/DATA/tox/ruamel.yaml +# toworkdir = /data1/DATA/tox/ruamel.yaml envlist = cs,py37,py27,py36,py35,py34,pypy,py27m [testenv] commands = - /bin/bash -c 'pytest -ra _test/test_*.py' + /bin/bash -c 'pytest _test/test_*.py' deps = pytest flake8==2.5.5 @@ -16,25 +16,12 @@ basepython = /opt/python/2.7.15m/bin/python [testenv:cs] basepython = python3.6 commands = - flake8 --exclude .tox,jabsy,jinja2,base,cmd,convert{posargs} - -# deprecation warning -[testenv:dw] -basepython = python3.7 -commands = - /bin/bash -c 'pytest _test/test_a*.py _test/test_z*.py' - -# deprecation warning fail -[testenv:dwf] -basepython = python3.7 -commands = - /bin/sed 's/collections.abc/collections/' -i .tox/dwf/lib/python3.7/site-packages/ruamel/yaml/comments.py - /bin/bash -c 'pytest --maxfail=2 _test/test_[a-vz]*.py' + flake8 --exclude ".tox,.#*,jabsy,jinja2,base,cmd,convert" {posargs} [testenv:pep8] basepython = python3.6 commands = - flake8 --exclude .tox,jabsy,jinja2,base,cmd,convert{posargs} + flake8 --exclude ".tox,.#*,jabsy,jinja2,base,cmd,convert" {posargs} [flake8] show-source = True |