Hello community, here is the log from the commit of package python-sybil for openSUSE:Factory checked in at 2020-09-04 11:00:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-sybil (Old) and /work/SRC/openSUSE:Factory/.python-sybil.new.3399 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sybil" Fri Sep 4 11:00:08 2020 rev:10 rq:830077 version:1.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-sybil/python-sybil.changes 2020-04-07 10:21:16.757826325 +0200 +++ /work/SRC/openSUSE:Factory/.python-sybil.new.3399/python-sybil.changes 2020-09-04 11:00:56.390682113 +0200 @@ -1,0 +2,8 @@ +Thu Aug 27 15:29:02 UTC 2020 - Marketa Calabkova <[email protected]> + +- update to 1.4.0 + * Support pytest 6 + * Have sybil support nested directories of source files + * Support a sequence of patterns rather than just one. + +------------------------------------------------------------------- Old: ---- sybil-1.3.0.tar.gz New: ---- sybil-1.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-sybil.spec ++++++ --- /var/tmp/diff_new_pack.hXZznW/_old 2020-09-04 11:01:01.382684788 +0200 +++ /var/tmp/diff_new_pack.hXZznW/_new 2020-09-04 11:01:01.386684789 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-sybil -Version: 1.3.0 +Version: 1.4.0 Release: 0 Summary: Automated testing of examples in documentation License: MIT @@ -34,7 +34,6 @@ Recommends: python-pytest Suggests: python-nose BuildArch: noarch - %python_subpackages %description @@ -55,7 +54,7 @@ %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%python_expand PYTHONPATH=%{buildroot}%{$python_sitelib} $python -m pytest +%pytest %files %{python_files} %doc README.rst docs/changes.rst ++++++ sybil-1.3.0.tar.gz -> sybil-1.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/PKG-INFO new/sybil-1.4.0/PKG-INFO --- old/sybil-1.3.0/PKG-INFO 2020-03-28 12:20:27.000000000 +0100 +++ new/sybil-1.4.0/PKG-INFO 2020-08-05 19:50:37.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: sybil -Version: 1.3.0 +Version: 1.4.0 Summary: Automated testing for the examples in your documentation. Home-page: https://github.com/cjw296/sybil Author: Chris Withers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/docs/changes.rst new/sybil-1.4.0/docs/changes.rst --- old/sybil-1.3.0/docs/changes.rst 2020-03-28 12:20:10.000000000 +0100 +++ new/sybil-1.4.0/docs/changes.rst 2020-08-05 19:50:19.000000000 +0200 @@ -1,10 +1,22 @@ Changes ======= +1.4.0 (5 Aug 2020) +------------------ + +- Support nested directories of source files rather than just one directory. + +- Support multiple patterns of files to include. + +1.3.1 (29 Jul 2020) +------------------- + +- Support pytest 6. + 1.3.0 (28 Mar 2020) ------------------- -- Treat all documentation source files as being ``utf-8`` encoded. This can be overriden +- Treat all documentation source files as being ``utf-8`` encoded. This can be overridden by passing an encoding when instantiating a :class:`~sybil.Sybil`. 1.2.2 (20 Feb 2020) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/setup.py new/sybil-1.4.0/setup.py --- old/sybil-1.3.0/setup.py 2020-03-28 12:20:10.000000000 +0100 +++ new/sybil-1.4.0/setup.py 2020-08-05 19:50:19.000000000 +0200 @@ -9,7 +9,7 @@ setup( name='sybil', - version='1.3.0', + version='1.4.0', author='Chris Withers', author_email='[email protected]', license='MIT', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/sybil/integration/pytest.py new/sybil-1.4.0/sybil/integration/pytest.py --- old/sybil-1.3.0/sybil/integration/pytest.py 2020-03-28 12:20:10.000000000 +0100 +++ new/sybil-1.4.0/sybil/integration/pytest.py 2020-08-05 19:50:20.000000000 +0200 @@ -93,14 +93,19 @@ class SybilFile(pytest.File): - def __init__(self, path, parent, sybil): - super(SybilFile, self).__init__(path, parent) + def __init__(self, fspath, parent, sybil): + super(SybilFile, self).__init__(fspath, parent) self.sybil = sybil def collect(self): self.document = self.sybil.parse(self.fspath.strpath) for example in self.document: - yield SybilItem(self, self.sybil, example) + try: + from_parent = SybilItem.from_parent + except AttributeError: + yield SybilItem(self, self.sybil, example) + else: + yield from_parent(self, sybil=self.sybil, example=example) def setup(self): if self.sybil.setup: @@ -111,10 +116,15 @@ self.sybil.teardown(self.document.namespace) -def pytest_integration(sybil): +def pytest_integration(sybil, class_=SybilFile): def pytest_collect_file(parent, path): - if sybil.should_test_filename(path.basename): - return SybilFile(path, parent, sybil) + if sybil.should_test_path(path): + try: + from_parent = class_.from_parent + except AttributeError: + return class_(path, parent, sybil) + else: + return from_parent(parent, fspath=path, sybil=sybil) return pytest_collect_file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/sybil/sybil.py new/sybil-1.4.0/sybil/sybil.py --- old/sybil-1.3.0/sybil/sybil.py 2020-03-28 12:20:10.000000000 +0100 +++ new/sybil-1.4.0/sybil/sybil.py 2020-08-05 19:50:20.000000000 +0200 @@ -1,26 +1,33 @@ +import os import sys from fnmatch import fnmatch -from glob import glob -from os import listdir -from os.path import join, dirname, abspath +from os.path import join, dirname, abspath, split from .document import Document -class FilenameFilter(object): +class PathFilter(object): - def __init__(self, pattern, filenames, excludes): - self.pattern = pattern + def __init__(self, patterns, filenames, excludes): + self.patterns = patterns self.filenames = filenames self.excludes = excludes - def __call__(self, filename): + def __call__(self, path): + path = str(path) return ( - (fnmatch(filename, self.pattern) or filename in self.filenames) - and not any(fnmatch(filename, e) for e in self.excludes) + (any(fnmatch(path, e) for e in self.patterns) or (split(path)[-1] in self.filenames)) + and not any(fnmatch(path, e) for e in self.excludes) ) +def listdir(root): + root_to_ignore = len(root) + 1 + for directory, _, filenames in os.walk(root): + for filename in filenames: + yield os.path.join(directory, filename)[root_to_ignore:] + + class Sybil(object): """ An object to provide test runner integration for discovering examples @@ -41,8 +48,13 @@ An optional :func:`pattern <fnmatch.fnmatch>` used to match documentation source files that will be parsed for examples. + :param patterns: + An optional sequence of :func:`patterns <fnmatch.fnmatch>` used to match documentation source + files that will be parsed for examples. + :param filenames: - An optional :class:`set` of source file names that will be parsed for examples. + An optional :class:`set` of source file names that, if found anywhere within the + root ``path`` or its sub-directories, that will be parsed for examples. :param excludes: An optional sequence of :func:`patterns <fnmatch.fnmatch>` of source file names @@ -73,7 +85,7 @@ def __init__(self, parsers, pattern='', path='.', setup=None, teardown=None, fixtures=(), filenames=(), excludes=(), - encoding='utf-8'): + encoding='utf-8', patterns=()): self.parsers = parsers calling_filename = sys._getframe(1).f_globals.get('__file__') if calling_filename: @@ -81,7 +93,10 @@ else: start_path = path self.path = abspath(start_path) - self.should_test_filename = FilenameFilter(pattern, filenames, excludes) + patterns = list(patterns) + if pattern: + patterns.append(pattern) + self.should_test_path = PathFilter(patterns, filenames, excludes) self.setup = setup self.teardown = teardown self.fixtures = fixtures @@ -91,16 +106,18 @@ return Document.parse(path, *self.parsers, encoding=self.encoding) def all_documents(self): - for filename in sorted(listdir(self.path)): - if self.should_test_filename(filename): - yield self.parse(join(self.path, filename)) + for path in sorted(listdir(self.path)): + if self.should_test_path(path): + yield self.parse(join(self.path, path)) - def pytest(self): + def pytest(self, class_=None): """ The helper method for when you use :ref:`pytest_integration`. """ - from .integration.pytest import pytest_integration - return pytest_integration(self) + from .integration.pytest import pytest_integration, SybilFile + if class_ is None: + class_ = SybilFile + return pytest_integration(self, class_) def unittest(self): """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/sybil.egg-info/PKG-INFO new/sybil-1.4.0/sybil.egg-info/PKG-INFO --- old/sybil-1.3.0/sybil.egg-info/PKG-INFO 2020-03-28 12:20:27.000000000 +0100 +++ new/sybil-1.4.0/sybil.egg-info/PKG-INFO 2020-08-05 19:50:37.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: sybil -Version: 1.3.0 +Version: 1.4.0 Summary: Automated testing for the examples in your documentation. Home-page: https://github.com/cjw296/sybil Author: Chris Withers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/sybil.egg-info/SOURCES.txt new/sybil-1.4.0/sybil.egg-info/SOURCES.txt --- old/sybil-1.3.0/sybil.egg-info/SOURCES.txt 2020-03-28 12:20:27.000000000 +0100 +++ new/sybil-1.4.0/sybil.egg-info/SOURCES.txt 2020-08-05 19:50:37.000000000 +0200 @@ -53,6 +53,7 @@ tests/test_doc_example.py tests/test_doctest.py tests/test_functional.py +tests/test_pytest.py tests/test_skip.py tests/test_sybil.py tests/functional/functional_unittest/__init__.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/tests/test_pytest.py new/sybil-1.4.0/tests/test_pytest.py --- old/sybil-1.3.0/tests/test_pytest.py 1970-01-01 01:00:00.000000000 +0100 +++ new/sybil-1.4.0/tests/test_pytest.py 2020-08-05 19:50:20.000000000 +0200 @@ -0,0 +1,38 @@ +from py.path import local + +from sybil import Sybil + + +class MockFile(object): + def __init__(self, path, parent, sybil): + self.path = path + + +class TestCollectFile(object): + + def test_filenames(self, tmp_path): + pytest_collect_file = Sybil(parsers=[], filenames=['test.rst']).pytest(MockFile) + path = (tmp_path / 'test.rst') + path.write_text(u'') + local_path = local(path) + assert pytest_collect_file(None, local_path).path == local_path + + def test_fnmatch_pattern(self, tmp_path): + pytest_collect_file = Sybil(parsers=[], pattern='**/*.rst').pytest(MockFile) + path = (tmp_path / 'test.rst') + path.write_text(u'') + local_path = local(path) + assert pytest_collect_file(None, local_path).path == local_path + + def test_fnmatch_patterns(self, tmp_path): + pytest_collect_file = Sybil(parsers=[], patterns=['*.rst', '*.py']).pytest(MockFile) + rst_path = (tmp_path / 'test.rst') + rst_path.write_text(u'') + py_path = (tmp_path / 'test.py') + py_path.write_text(u'') + + local_path = local(rst_path) + assert pytest_collect_file(None, local_path).path == local_path + + local_path = local(py_path) + assert pytest_collect_file(None, local_path).path == local_path diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sybil-1.3.0/tests/test_sybil.py new/sybil-1.4.0/tests/test_sybil.py --- old/sybil-1.3.0/tests/test_sybil.py 2020-03-28 12:20:10.000000000 +0100 +++ new/sybil-1.4.0/tests/test_sybil.py 2020-08-05 19:50:20.000000000 +0200 @@ -1,5 +1,6 @@ from __future__ import print_function +import os import re from functools import partial from os.path import split @@ -237,20 +238,38 @@ class TestFiltering(object): - def check(self, sybil, expected): - assert expected == [split(d.path)[-1] for d in sybil.all_documents()] + def check(self, tmp_path, sybil, expected): + assert expected == [d.path[len(str(tmp_path))+1:].split(os.sep) + for d in sybil.all_documents()] def test_excludes(self, tmp_path): (tmp_path / 'foo.txt').write_text(u'') (tmp_path / 'bar.txt').write_text(u'') sybil = Sybil([], path=str(tmp_path), pattern='*.txt', excludes=['bar.txt']) - self.check(sybil, expected=['foo.txt']) + self.check(tmp_path, sybil, expected=[['foo.txt']]) def test_filenames(self, tmp_path): (tmp_path / 'foo.txt').write_text(u'') (tmp_path / 'bar.txt').write_text(u'') + (tmp_path / 'baz').mkdir() + (tmp_path / 'baz' / 'bar.txt').write_text(u'') sybil = Sybil([], path=str(tmp_path), filenames=['bar.txt']) - self.check(sybil, expected=['bar.txt']) + self.check(tmp_path, sybil, expected=[['bar.txt'], ['baz', 'bar.txt']]) + + def test_glob_patterns(self, tmp_path): + (tmp_path / 'middle').mkdir() + interesting = (tmp_path / 'middle' / 'interesting') + interesting.mkdir() + boring = (tmp_path / 'middle' / 'boring') + boring.mkdir() + (interesting / 'foo.txt').write_text(u'') + (boring / 'bad1.txt').write_text(u'') + (tmp_path / 'bad2.txt').write_text(u'') + sybil = Sybil([], + path=str(tmp_path), + pattern='**middle/*.txt', + excludes=['**/boring/*.txt']) + self.check(tmp_path, sybil, expected=[['middle', 'interesting', 'foo.txt']]) def check_into_namespace(example):
