From: DongHun Kwak Date: Tue, 5 Mar 2024 09:28:34 +0000 (+0900) Subject: Imported Upstream version 1.11.0 X-Git-Tag: upstream/1.11.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7508ec5f0e30029c15cda5d30b2525ebb643e6d3;p=platform%2Fupstream%2Fpython3-py.git Imported Upstream version 1.11.0 --- diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0192a42..564aa0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - python: ["2.7", "3.5", "3.6", "3.7", "3.8", "pypy3"] + python: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy3"] os: [ubuntu-latest, windows-latest] include: - python: "2.7" @@ -23,22 +23,20 @@ jobs: tox_env: "py37-pytest30" - python: "3.8" tox_env: "py38-pytest30" + - python: "3.9" + tox_env: "py39-pytest30" - python: "pypy3" tox_env: "pypy3-pytest30" steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - - name: Install tox - run: | - python -m pip install --upgrade pip - pip install tox - name: Test run: | - tox -e ${{ matrix.tox_env }} + pipx run tox -e ${{ matrix.tox_env }} deploy: @@ -49,9 +47,9 @@ jobs: needs: build steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: "3.7" - name: Install wheel diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 90e5905..47c6fdb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,10 @@ +1.11.0 (2021-11-04) +=================== + +- Support Python 3.11 +- Support ``NO_COLOR`` environment variable +- Update vendored apipkg: 1.5 => 2.0 + 1.10.0 (2020-12-12) =================== diff --git a/doc/install.txt b/doc/install.txt index 5b662e0..93c79e3 100644 --- a/doc/install.txt +++ b/doc/install.txt @@ -71,7 +71,10 @@ Mailing list and issue tracker - `py-dev developers list`_ and `commit mailing list`_. -- #pylib on irc.freenode.net IRC channel for random questions. +- ``#pytest`` `on irc.libera.chat `_ IRC + channel for random questions (using an IRC client, `via webchat + `_, or `via Matrix + `_). - `issue tracker`_ use the issue tracker to report bugs or request features. diff --git a/py/_io/terminalwriter.py b/py/_io/terminalwriter.py index be55986..442ca23 100644 --- a/py/_io/terminalwriter.py +++ b/py/_io/terminalwriter.py @@ -133,6 +133,8 @@ def should_do_markup(file): return True if os.environ.get('PY_COLORS') == '0': return False + if 'NO_COLOR' in os.environ: + return False return hasattr(file, 'isatty') and file.isatty() \ and os.environ.get('TERM') != 'dumb' \ and not (sys.platform.startswith('java') and os._name == 'nt') diff --git a/py/_vendored_packages/apipkg-1.5.dist-info/INSTALLER b/py/_vendored_packages/apipkg-1.5.dist-info/INSTALLER deleted file mode 100644 index a1b589e..0000000 --- a/py/_vendored_packages/apipkg-1.5.dist-info/INSTALLER +++ /dev/null @@ -1 +0,0 @@ -pip diff --git a/py/_vendored_packages/apipkg-1.5.dist-info/METADATA b/py/_vendored_packages/apipkg-1.5.dist-info/METADATA deleted file mode 100644 index ac14b4b..0000000 --- a/py/_vendored_packages/apipkg-1.5.dist-info/METADATA +++ /dev/null @@ -1,115 +0,0 @@ -Metadata-Version: 2.1 -Name: apipkg -Version: 1.5 -Summary: apipkg: namespace control and lazy-import mechanism -Home-page: https://github.com/pytest-dev/apipkg -Author: holger krekel -Maintainer: Ronny Pfannschmidt -Maintainer-email: opensource@ronnypfannschmidt.de -License: MIT License -Platform: unix -Platform: linux -Platform: osx -Platform: cygwin -Platform: win32 -Classifier: Development Status :: 4 - Beta -Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: POSIX -Classifier: Operating System :: Microsoft :: Windows -Classifier: Operating System :: MacOS :: MacOS X -Classifier: Topic :: Software Development :: Libraries -Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.4 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 -Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* - -Welcome to apipkg! ------------------------- - -With apipkg you can control the exported namespace of a Python package and -greatly reduce the number of imports for your users. -It is a `small pure Python module`_ that works on CPython 2.7 and 3.4+, -Jython and PyPy. It cooperates well with Python's ``help()`` system, -custom importers (PEP302) and common command-line completion tools. - -Usage is very simple: you can require 'apipkg' as a dependency or you -can copy paste the ~200 lines of code into your project. - - -Tutorial example -------------------- - -Here is a simple ``mypkg`` package that specifies one namespace -and exports two objects imported from different modules:: - - # mypkg/__init__.py - import apipkg - apipkg.initpkg(__name__, { - 'path': { - 'Class1': "_mypkg.somemodule:Class1", - 'clsattr': "_mypkg.othermodule:Class2.attr", - } - } - -The package is initialized with a dictionary as namespace. - -You need to create a ``_mypkg`` package with a ``somemodule.py`` -and ``othermodule.py`` containing the respective classes. -The ``_mypkg`` is not special - it's a completely -regular Python package. - -Namespace dictionaries contain ``name: value`` mappings -where the value may be another namespace dictionary or -a string specifying an import location. On accessing -an namespace attribute an import will be performed:: - - >>> import mypkg - >>> mypkg.path - - >>> mypkg.path.Class1 # '_mypkg.somemodule' gets imported now - - >>> mypkg.path.clsattr # '_mypkg.othermodule' gets imported now - 4 # the value of _mypkg.othermodule.Class2.attr - -The ``mypkg.path`` namespace and its two entries are -loaded when they are accessed. This means: - -* lazy loading - only what is actually needed is ever loaded - -* only the root "mypkg" ever needs to be imported to get - access to the complete functionality - -* the underlying modules are also accessible, for example:: - - from mypkg.sub import Class1 - - -Including apipkg in your package --------------------------------------- - -If you don't want to add an ``apipkg`` dependency to your package you -can copy the `apipkg.py`_ file somewhere to your own package, -for example ``_mypkg/apipkg.py`` in the above example. You -then import the ``initpkg`` function from that new place and -are good to go. - -.. _`small pure Python module`: -.. _`apipkg.py`: https://github.com/pytest-dev/apipkg/blob/master/src/apipkg/__init__.py - -Feedback? ------------------------ - -If you have questions you are welcome to - -* join the #pylib channel on irc.freenode.net -* create an issue on https://github.com/pytest-dev/apipkg/issues - -have fun, -holger krekel - - diff --git a/py/_vendored_packages/apipkg-1.5.dist-info/RECORD b/py/_vendored_packages/apipkg-1.5.dist-info/RECORD deleted file mode 100644 index 8611704..0000000 --- a/py/_vendored_packages/apipkg-1.5.dist-info/RECORD +++ /dev/null @@ -1,10 +0,0 @@ -../../../../home/ran/.cache/pycache/tmp/pip-target-oxds71ih/lib/python/apipkg/__init__.cpython-39.pyc,, -../../../../home/ran/.cache/pycache/tmp/pip-target-oxds71ih/lib/python/apipkg/version.cpython-39.pyc,, -apipkg-1.5.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 -apipkg-1.5.dist-info/METADATA,sha256=tIG1DSBzSeqmSRpOKHSEBmT1eOPdK8xK01xAIADuks4,3800 -apipkg-1.5.dist-info/RECORD,, -apipkg-1.5.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 -apipkg-1.5.dist-info/WHEEL,sha256=gduuPyBvFJQSQ0zdyxF7k0zynDXbIbvg5ZBHoXum5uk,110 -apipkg-1.5.dist-info/top_level.txt,sha256=3TGS6nmN7kjxhUK4LpPCB3QkQI34QYGrT0ZQGWajoZ8,7 -apipkg/__init__.py,sha256=VogR4mDwYmeOdJnjGi-RoMB1qJnD6_puDYj_nRolzhM,6707 -apipkg/version.py,sha256=YN6DnKyEPqjDAauJuwJRG9vlKbWVLd9gAbH7mkQXXNo,114 diff --git a/py/_vendored_packages/apipkg-1.5.dist-info/REQUESTED b/py/_vendored_packages/apipkg-1.5.dist-info/REQUESTED deleted file mode 100644 index e69de29..0000000 diff --git a/py/_vendored_packages/apipkg-1.5.dist-info/WHEEL b/py/_vendored_packages/apipkg-1.5.dist-info/WHEEL deleted file mode 100644 index 1316c41..0000000 --- a/py/_vendored_packages/apipkg-1.5.dist-info/WHEEL +++ /dev/null @@ -1,6 +0,0 @@ -Wheel-Version: 1.0 -Generator: bdist_wheel (0.31.1) -Root-Is-Purelib: true -Tag: py2-none-any -Tag: py3-none-any - diff --git a/py/_vendored_packages/apipkg-1.5.dist-info/top_level.txt b/py/_vendored_packages/apipkg-1.5.dist-info/top_level.txt deleted file mode 100644 index e2221c8..0000000 --- a/py/_vendored_packages/apipkg-1.5.dist-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -apipkg diff --git a/py/_vendored_packages/apipkg-2.0.0.dist-info/INSTALLER b/py/_vendored_packages/apipkg-2.0.0.dist-info/INSTALLER new file mode 100644 index 0000000..a1b589e --- /dev/null +++ b/py/_vendored_packages/apipkg-2.0.0.dist-info/INSTALLER @@ -0,0 +1 @@ +pip diff --git a/py/_vendored_packages/apipkg-2.0.0.dist-info/LICENSE b/py/_vendored_packages/apipkg-2.0.0.dist-info/LICENSE new file mode 100644 index 0000000..ff33b8f --- /dev/null +++ b/py/_vendored_packages/apipkg-2.0.0.dist-info/LICENSE @@ -0,0 +1,18 @@ + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/py/_vendored_packages/apipkg-2.0.0.dist-info/METADATA b/py/_vendored_packages/apipkg-2.0.0.dist-info/METADATA new file mode 100644 index 0000000..7eea770 --- /dev/null +++ b/py/_vendored_packages/apipkg-2.0.0.dist-info/METADATA @@ -0,0 +1,125 @@ +Metadata-Version: 2.1 +Name: apipkg +Version: 2.0.0 +Summary: apipkg: namespace control and lazy-import mechanism +Home-page: https://github.com/pytest-dev/apipkg +Author: holger krekel +Maintainer: Ronny Pfannschmidt +Maintainer-email: opensource@ronnypfannschmidt.de +License: MIT +Platform: unix +Platform: linux +Platform: osx +Platform: cygwin +Platform: win32 +Classifier: Development Status :: 4 - Beta +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: MacOS :: MacOS X +Classifier: Operating System :: Microsoft :: Windows +Classifier: Operating System :: POSIX +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: Implementation :: CPython +Classifier: Topic :: Software Development :: Libraries +Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7 +Description-Content-Type: text/x-rst +License-File: LICENSE + +Welcome to apipkg ! +------------------- + +With apipkg you can control the exported namespace of a Python package and +greatly reduce the number of imports for your users. +It is a `small pure Python module`_ that works on CPython 2.7 and 3.4+, +Jython and PyPy. It cooperates well with Python's ``help()`` system, +custom importers (PEP302) and common command-line completion tools. + +Usage is very simple: you can require 'apipkg' as a dependency or you +can copy paste the ~200 lines of code into your project. + + +Tutorial example +------------------- + +Here is a simple ``mypkg`` package that specifies one namespace +and exports two objects imported from different modules:: + + + # mypkg/__init__.py + import apipkg + apipkg.initpkg(__name__, { + 'path': { + 'Class1': "_mypkg.somemodule:Class1", + 'clsattr': "_mypkg.othermodule:Class2.attr", + } + } + +The package is initialized with a dictionary as namespace. + +You need to create a ``_mypkg`` package with a ``somemodule.py`` +and ``othermodule.py`` containing the respective classes. +The ``_mypkg`` is not special - it's a completely +regular Python package. + +Namespace dictionaries contain ``name: value`` mappings +where the value may be another namespace dictionary or +a string specifying an import location. On accessing +an namespace attribute an import will be performed:: + + >>> import mypkg + >>> mypkg.path + + >>> mypkg.path.Class1 # '_mypkg.somemodule' gets imported now + + >>> mypkg.path.clsattr # '_mypkg.othermodule' gets imported now + 4 # the value of _mypkg.othermodule.Class2.attr + +The ``mypkg.path`` namespace and its two entries are +loaded when they are accessed. This means: + +* lazy loading - only what is actually needed is ever loaded + +* only the root "mypkg" ever needs to be imported to get + access to the complete functionality + +* the underlying modules are also accessible, for example:: + + from mypkg.sub import Class1 + + +Including apipkg in your package +-------------------------------------- + +If you don't want to add an ``apipkg`` dependency to your package you +can copy the `apipkg.py`_ file somewhere to your own package, +for example ``_mypkg/apipkg.py`` in the above example. You +then import the ``initpkg`` function from that new place and +are good to go. + +.. _`small pure Python module`: +.. _`apipkg.py`: https://github.com/pytest-dev/apipkg/blob/master/src/apipkg/__init__.py + +Feedback? +----------------------- + +If you have questions you are welcome to + +* join the **#pytest** channel on irc.libera.chat_ + (using an IRC client, via webchat_, or via Matrix_). +* create an issue on the bugtracker_ + +.. _irc.libera.chat: ircs://irc.libera.chat:6697/#pytest +.. _webchat: https://web.libera.chat/#pytest +.. _matrix: https://matrix.to/#/%23pytest:libera.chat +.. _bugtracker: https://github.com/pytest-dev/apipkg/issues + + diff --git a/py/_vendored_packages/apipkg-2.0.0.dist-info/RECORD b/py/_vendored_packages/apipkg-2.0.0.dist-info/RECORD new file mode 100644 index 0000000..357b8b9 --- /dev/null +++ b/py/_vendored_packages/apipkg-2.0.0.dist-info/RECORD @@ -0,0 +1,11 @@ +apipkg-2.0.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +apipkg-2.0.0.dist-info/LICENSE,sha256=6J7tEHTTqUMZi6E5uAhE9bRFuGC7p0qK6twGEFZhZOo,1054 +apipkg-2.0.0.dist-info/METADATA,sha256=GqNwkxraK5UTxObLVXTLc2UqktOPwZnKqdk2ThzHX0A,4292 +apipkg-2.0.0.dist-info/RECORD,, +apipkg-2.0.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +apipkg-2.0.0.dist-info/WHEEL,sha256=WzZ8cwjh8l0jtULNjYq1Hpr-WCqCRgPr--TX4P5I1Wo,110 +apipkg-2.0.0.dist-info/top_level.txt,sha256=3TGS6nmN7kjxhUK4LpPCB3QkQI34QYGrT0ZQGWajoZ8,7 +apipkg/__init__.py,sha256=gpbD3O57S9f-LsO2e-XwI6IGISayicfnCq3B5y_8frg,6978 +apipkg/__pycache__/__init__.cpython-39.pyc,, +apipkg/__pycache__/version.cpython-39.pyc,, +apipkg/version.py,sha256=bgZFg-f3UKhgE-z2w8RoFrwqRBzJBZkM4_jKFiYB9eU,142 diff --git a/py/_vendored_packages/apipkg-2.0.0.dist-info/REQUESTED b/py/_vendored_packages/apipkg-2.0.0.dist-info/REQUESTED new file mode 100644 index 0000000..e69de29 diff --git a/py/_vendored_packages/apipkg-2.0.0.dist-info/WHEEL b/py/_vendored_packages/apipkg-2.0.0.dist-info/WHEEL new file mode 100644 index 0000000..b733a60 --- /dev/null +++ b/py/_vendored_packages/apipkg-2.0.0.dist-info/WHEEL @@ -0,0 +1,6 @@ +Wheel-Version: 1.0 +Generator: bdist_wheel (0.37.0) +Root-Is-Purelib: true +Tag: py2-none-any +Tag: py3-none-any + diff --git a/py/_vendored_packages/apipkg-2.0.0.dist-info/top_level.txt b/py/_vendored_packages/apipkg-2.0.0.dist-info/top_level.txt new file mode 100644 index 0000000..e2221c8 --- /dev/null +++ b/py/_vendored_packages/apipkg-2.0.0.dist-info/top_level.txt @@ -0,0 +1 @@ +apipkg diff --git a/py/_vendored_packages/apipkg/__init__.py b/py/_vendored_packages/apipkg/__init__.py index 9318048..350d8c4 100644 --- a/py/_vendored_packages/apipkg/__init__.py +++ b/py/_vendored_packages/apipkg/__init__.py @@ -9,7 +9,7 @@ import os import sys from types import ModuleType -from .version import version as __version__ +from .version import version as __version__ # NOQA:F401 def _py_abspath(path): @@ -17,7 +17,7 @@ def _py_abspath(path): special version of abspath that will leave paths from jython jars alone """ - if path.startswith('__pyclasspath__'): + if path.startswith("__pyclasspath__"): return path else: @@ -28,6 +28,7 @@ def distribution_version(name): """try to get the version of the named distribution, returs None on failure""" from pkg_resources import get_distribution, DistributionNotFound + try: dist = get_distribution(name) except DistributionNotFound: @@ -41,35 +42,37 @@ def initpkg(pkgname, exportdefs, attr=None, eager=False): attr = attr or {} oldmod = sys.modules.get(pkgname) d = {} - f = getattr(oldmod, '__file__', None) + f = getattr(oldmod, "__file__", None) if f: f = _py_abspath(f) - d['__file__'] = f - if hasattr(oldmod, '__version__'): - d['__version__'] = oldmod.__version__ - if hasattr(oldmod, '__loader__'): - d['__loader__'] = oldmod.__loader__ - if hasattr(oldmod, '__path__'): - d['__path__'] = [_py_abspath(p) for p in oldmod.__path__] - if hasattr(oldmod, '__package__'): - d['__package__'] = oldmod.__package__ - if '__doc__' not in exportdefs and getattr(oldmod, '__doc__', None): - d['__doc__'] = oldmod.__doc__ + d["__file__"] = f + if hasattr(oldmod, "__version__"): + d["__version__"] = oldmod.__version__ + if hasattr(oldmod, "__loader__"): + d["__loader__"] = oldmod.__loader__ + if hasattr(oldmod, "__path__"): + d["__path__"] = [_py_abspath(p) for p in oldmod.__path__] + if hasattr(oldmod, "__package__"): + d["__package__"] = oldmod.__package__ + if "__doc__" not in exportdefs and getattr(oldmod, "__doc__", None): + d["__doc__"] = oldmod.__doc__ + d["__spec__"] = getattr(oldmod, "__spec__", None) d.update(attr) if hasattr(oldmod, "__dict__"): oldmod.__dict__.update(d) mod = ApiModule(pkgname, exportdefs, implprefix=pkgname, attr=d) sys.modules[pkgname] = mod # eagerload in bypthon to avoid their monkeypatching breaking packages - if 'bpython' in sys.modules or eager: + if "bpython" in sys.modules or eager: for module in list(sys.modules.values()): if isinstance(module, ApiModule): module.__dict__ + return mod def importobj(modpath, attrname): """imports a module, then resolves the attrname on it""" - module = __import__(modpath, None, None, ['__doc__']) + module = __import__(modpath, None, None, ["__doc__"]) if not attrname: return module @@ -82,20 +85,22 @@ def importobj(modpath, attrname): class ApiModule(ModuleType): """the magical lazy-loading module standing""" + def __docget(self): try: return self.__doc except AttributeError: - if '__doc__' in self.__map__: - return self.__makeattr('__doc__') + if "__doc__" in self.__map__: + return self.__makeattr("__doc__") def __docset(self, value): self.__doc = value + __doc__ = property(__docget, __docset) def __init__(self, name, importspec, implprefix=None, attr=None): self.__name__ = name - self.__all__ = [x for x in importspec if x != '__onfirstaccess__'] + self.__all__ = [x for x in importspec if x != "__onfirstaccess__"] self.__map__ = {} self.__implprefix__ = implprefix or name if attr: @@ -104,47 +109,47 @@ class ApiModule(ModuleType): setattr(self, name, val) for name, importspec in importspec.items(): if isinstance(importspec, dict): - subname = '%s.%s' % (self.__name__, name) + subname = "{}.{}".format(self.__name__, name) apimod = ApiModule(subname, importspec, implprefix) sys.modules[subname] = apimod setattr(self, name, apimod) else: - parts = importspec.split(':') + parts = importspec.split(":") modpath = parts.pop(0) attrname = parts and parts[0] or "" - if modpath[0] == '.': + if modpath[0] == ".": modpath = implprefix + modpath if not attrname: - subname = '%s.%s' % (self.__name__, name) + subname = "{}.{}".format(self.__name__, name) apimod = AliasModule(subname, modpath) sys.modules[subname] = apimod - if '.' not in name: + if "." not in name: setattr(self, name, apimod) else: self.__map__[name] = (modpath, attrname) def __repr__(self): repr_list = [] - if hasattr(self, '__version__'): + if hasattr(self, "__version__"): repr_list.append("version=" + repr(self.__version__)) - if hasattr(self, '__file__'): - repr_list.append('from ' + repr(self.__file__)) + if hasattr(self, "__file__"): + repr_list.append("from " + repr(self.__file__)) if repr_list: - return '' % (self.__name__, " ".join(repr_list)) - return '' % (self.__name__,) + return "".format(self.__name__, " ".join(repr_list)) + return "".format(self.__name__) def __makeattr(self, name): """lazily compute value for name or raise AttributeError if unknown.""" # print "makeattr", self.__name__, name target = None - if '__onfirstaccess__' in self.__map__: - target = self.__map__.pop('__onfirstaccess__') + if "__onfirstaccess__" in self.__map__: + target = self.__map__.pop("__onfirstaccess__") importobj(*target)() try: modpath, attrname = self.__map__[name] except KeyError: - if target is not None and name != '__onfirstaccess__': + if target is not None and name != "__onfirstaccess__": # retry, onfirstaccess might have set attrs return getattr(self, name) raise AttributeError(name) @@ -163,10 +168,10 @@ class ApiModule(ModuleType): def __dict__(self): # force all the content of the module # to be loaded when __dict__ is read - dictdescr = ModuleType.__dict__['__dict__'] + dictdescr = ModuleType.__dict__["__dict__"] dict = dictdescr.__get__(self) if dict is not None: - hasattr(self, 'some') + hasattr(self, "some") for name in self.__all__: try: self.__makeattr(name) @@ -186,19 +191,22 @@ def AliasModule(modname, modpath, attrname=None): mod.append(x) return mod[0] - class AliasModule(ModuleType): + x = modpath + ("." + attrname if attrname else "") + repr_result = "".format(modname, x) + class AliasModule(ModuleType): def __repr__(self): - x = modpath - if attrname: - x += "." + attrname - return '' % (modname, x) + return repr_result def __getattribute__(self, name): try: return getattr(getmod(), name) except ImportError: - return None + if modpath == "pytest" and attrname is None: + # hack for pylibs py.test + return None + else: + raise def __setattr__(self, name, value): setattr(getmod(), name, value) diff --git a/py/_vendored_packages/apipkg/version.py b/py/_vendored_packages/apipkg/version.py index c25fc7c..c5b4e0e 100644 --- a/py/_vendored_packages/apipkg/version.py +++ b/py/_vendored_packages/apipkg/version.py @@ -1,4 +1,5 @@ # coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control -version = '1.5' +version = '2.0.0' +version_tuple = (2, 0, 0) diff --git a/py/_vendored_packages/iniconfig-1.1.1.dist-info/RECORD b/py/_vendored_packages/iniconfig-1.1.1.dist-info/RECORD index 73a6fe1..1682333 100644 --- a/py/_vendored_packages/iniconfig-1.1.1.dist-info/RECORD +++ b/py/_vendored_packages/iniconfig-1.1.1.dist-info/RECORD @@ -1,4 +1,3 @@ -../../../../home/ran/.cache/pycache/tmp/pip-target-oxds71ih/lib/python/iniconfig/__init__.cpython-39.pyc,, iniconfig-1.1.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 iniconfig-1.1.1.dist-info/LICENSE,sha256=KvaAw570k_uCgwNW0dPfGstaBgM8ui3sehniHKp3qGY,1061 iniconfig-1.1.1.dist-info/METADATA,sha256=_4-oFKpRXuZv5rzepScpXRwhq6DzqsgbnA5ZpgMUMcs,2405 @@ -8,4 +7,5 @@ iniconfig-1.1.1.dist-info/WHEEL,sha256=ADKeyaGyKF5DwBNE0sRE5pvW-bSkFMJfBuhzZ3rce iniconfig-1.1.1.dist-info/top_level.txt,sha256=7KfM0fugdlToj9UW7enKXk2HYALQD8qHiyKtjhSzgN8,10 iniconfig/__init__.py,sha256=-pBe5AF_6aAwo1CxJQ8i_zJq6ejc6IxHta7qk2tNJhY,5208 iniconfig/__init__.pyi,sha256=-4KOctzq28ohRmTZsqlH6aylyFqsNKxYqtk1dteypi4,1205 +iniconfig/__pycache__/__init__.cpython-39.pyc,, iniconfig/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e386ea0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools", + "setuptools_scm[toml]", +] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index d097daa..5948ef0 100644 --- a/setup.py +++ b/setup.py @@ -7,11 +7,11 @@ def main(): description='library with cross-python path, ini-parsing, io, code, log facilities', long_description=open('README.rst').read(), use_scm_version={"write_to": "py/_version.py"}, - setup_requires=["setuptools-scm"], + setup_requires=["setuptools_scm"], url='https://py.readthedocs.io/', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', author='holger krekel, Ronny Pfannschmidt, Benjamin Peterson and others', author_email='pytest-dev@python.org', classifiers=['Development Status :: 6 - Mature', @@ -30,6 +30,9 @@ def main(): 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', ], diff --git a/testing/io_/test_terminalwriter.py b/testing/io_/test_terminalwriter.py index 1eef7f7..44b4f1d 100644 --- a/testing/io_/test_terminalwriter.py +++ b/testing/io_/test_terminalwriter.py @@ -303,3 +303,39 @@ def test_should_do_markup_PY_COLORS_eq_0(monkeypatch): tw.line("hello", bold=True) s = f.getvalue() assert s == "hello\n" + +def test_should_do_markup(monkeypatch): + monkeypatch.delenv("PY_COLORS", raising=False) + monkeypatch.delenv("NO_COLOR", raising=False) + + should_do_markup = terminalwriter.should_do_markup + + f = py.io.TextIO() + f.isatty = lambda: True + + assert should_do_markup(f) is True + + # NO_COLOR without PY_COLORS. + monkeypatch.setenv("NO_COLOR", "0") + assert should_do_markup(f) is False + monkeypatch.setenv("NO_COLOR", "1") + assert should_do_markup(f) is False + monkeypatch.setenv("NO_COLOR", "any") + assert should_do_markup(f) is False + + # PY_COLORS overrides NO_COLOR ("0" and "1" only). + monkeypatch.setenv("PY_COLORS", "1") + assert should_do_markup(f) is True + monkeypatch.setenv("PY_COLORS", "0") + assert should_do_markup(f) is False + # Uses NO_COLOR. + monkeypatch.setenv("PY_COLORS", "any") + assert should_do_markup(f) is False + monkeypatch.delenv("NO_COLOR") + assert should_do_markup(f) is True + + # Back to defaults. + monkeypatch.delenv("PY_COLORS") + assert should_do_markup(f) is True + f.isatty = lambda: False + assert should_do_markup(f) is False diff --git a/testing/log/test_warning.py b/testing/log/test_warning.py index a460c31..36efec9 100644 --- a/testing/log/test_warning.py +++ b/testing/log/test_warning.py @@ -8,8 +8,7 @@ import py mypath = py.path.local(__file__).new(ext=".py") -win = sys.platform.startswith('win') -pytestmark = pytest.mark.skipif(win and LooseVersion(pytest.__version__) >= LooseVersion('3.1'), +pytestmark = pytest.mark.skipif(LooseVersion(pytest.__version__) >= LooseVersion('3.1'), reason='apiwarn is not compatible with pytest >= 3.1 (#162)')