Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-itypes for openSUSE:Factory checked in at 2021-08-30 13:55:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-itypes (Old)
and /work/SRC/openSUSE:Factory/.python-itypes.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-itypes"
Mon Aug 30 13:55:07 2021 rev:2 rq:914895 version:1.2.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-itypes/python-itypes.changes 2019-03-01 16:46:57.741809616 +0100
+++ /work/SRC/openSUSE:Factory/.python-itypes.new.1899/python-itypes.changes 2021-08-30 13:55:23.133836055 +0200
@@ -1,0 +2,26 @@
+Sun Aug 29 19:21:21 UTC 2021 - Matej Cepl
+
+- Enable tests (we need to get source tarball from GitHub
+ directly).
+
+-------------------------------------------------------------------
+Sun Aug 29 19:18:05 UTC 2021 - mcepl@cepl.eu
+
+- Update to version 1.2.0:
+ * adding long description content type text/markdown
+ * adding read func in setup.py
+ * removing python v3.3 support
+ * fix collections deprecation warning
+ * Create LICENSE.md
+ * Add Python 2/3 trove classifiers to setup.py
+ * Add support for running tests on Travis
+ * Add 'itypes.Object'
+ * Update README.md
+
+-------------------------------------------------------------------
+Wed Aug 25 10:16:51 UTC 2021 - John Paul Adrian Glaubitz
+
+- Update to 1.2.0
+ * fix collections deprecation warning
+
+-------------------------------------------------------------------
Old:
----
LICENSE.md
itypes-1.1.0.tar.gz
New:
----
_service
_servicedata
itypes-1.2.0.tar.gz
itypes.obsinfo
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-itypes.spec ++++++
--- /var/tmp/diff_new_pack.8BdWLB/_old 2021-08-30 13:55:23.777836882 +0200
+++ /var/tmp/diff_new_pack.8BdWLB/_new 2021-08-30 13:55:23.781836886 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-itypes
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,14 +18,14 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-itypes
-Version: 1.1.0
+Version: 1.2.0
Release: 0
Summary: Basic immutable container types for Python
License: BSD-2-Clause
Group: Development/Languages/Python
URL: https://github.com/tomchristie/itypes
-Source: https://files.pythonhosted.org/packages/source/i/itypes/itypes-%{version}.tar.gz
-Source1: https://raw.githubusercontent.com/tomchristie/itypes/master/LICENSE.md
+Source: itypes-%{version}.tar.gz
+BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
@@ -41,8 +41,7 @@
when you want to create custom types with restricted, immutable interfaces.
%prep
-%setup -q -n itypes-%{version}
-cp %{SOURCE1} .
+%autosetup -p1 -n itypes-%{version}
%build
%python_build
@@ -51,6 +50,9 @@
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
+%check
+%pytest tests.py
+
%files %{python_files}
%license LICENSE.md
%{python_sitelib}/itypes.py*
++++++ _service ++++++
<services>
<service name="obs_scm" mode="disabled">
<param name="url">https://github.com/PavanTatikonda/itypes.git</param>
<param name="scm">git</param>
<param name="revision">1.2.0</param>
<param name="versionformat">@PARENT_TAG@</param>
<!-- param name="versionrewrite-pattern">v(.*)</param -->
<param name="exclude">.git*</param>
<param name="changesgenerate">enable</param>
<param name="changesauthor">mcepl@cepl.eu</param>
</service>
<service mode="disabled" name="tar" />
<service name="recompress" mode="disabled">
<param name="file">*.tar</param>
<param name="compression">gz</param>
</service>
<service name="set_version" mode="disabled" />
</services>
++++++ _servicedata ++++++
<servicedata>
<service name="tar_scm">
<param name="url">https://github.com/PavanTatikonda/itypes.git</param>
<param name="changesrevision">86b6fb6aea3546fd86eb319bd06a82a655a94a97</param></service></servicedata>++++++ itypes-1.1.0.tar.gz -> itypes-1.2.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/.gitignore new/itypes-1.2.0/.gitignore
--- old/itypes-1.1.0/.gitignore 1970-01-01 01:00:00.000000000 +0100
+++ new/itypes-1.2.0/.gitignore 2020-04-19 23:46:35.000000000 +0200
@@ -0,0 +1,11 @@
+*.pyc
+*~
+.*
+
+/*.egg-info/
+/dist/
+/env/
+/htmlcov/
+
+!.gitignore
+!.travis.yml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/.travis.yml new/itypes-1.2.0/.travis.yml
--- old/itypes-1.1.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/itypes-1.2.0/.travis.yml 2020-04-19 23:46:35.000000000 +0200
@@ -0,0 +1,14 @@
+language: python
+cache: pip
+
+python:
+ - "2.7"
+ - "3.4"
+ - "3.5"
+ - "3.6"
+
+install:
+ - pip install -r requirements.txt
+
+script:
+ - ./runtests
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/LICENSE.md new/itypes-1.2.0/LICENSE.md
--- old/itypes-1.1.0/LICENSE.md 1970-01-01 01:00:00.000000000 +0100
+++ new/itypes-1.2.0/LICENSE.md 2020-04-19 23:46:35.000000000 +0200
@@ -0,0 +1,29 @@
+# License
+
+Copyright �� 2017-present, Tom Christie.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/PKG-INFO new/itypes-1.2.0/PKG-INFO
--- old/itypes-1.1.0/PKG-INFO 2016-01-07 11:58:47.000000000 +0100
+++ new/itypes-1.2.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-Metadata-Version: 1.1
-Name: itypes
-Version: 1.1.0
-Summary: Simple immutable types for python.
-Home-page: http://github.com/tomchristie/itypes
-Author: Tom Christie
-Author-email: tom@tomchristie.com
-License: BSD
-Description: UNKNOWN
-Platform: UNKNOWN
-Classifier: Development Status :: 3 - Alpha
-Classifier: Environment :: Web Environment
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Topic :: Internet :: WWW/HTTP
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/README.md new/itypes-1.2.0/README.md
--- old/itypes-1.1.0/README.md 1970-01-01 01:00:00.000000000 +0100
+++ new/itypes-1.2.0/README.md 2020-04-19 23:46:35.000000000 +0200
@@ -0,0 +1,153 @@
+# itypes
+
+[![Build Status](https://travis-ci.org/PavanTatikonda/itypes.svg?branch=master)](https://travis-ci.org/PavanTatikonda/itypes)
+
+Basic immutable container types for Python.
+
+A simple implementation that's designed for simplicity over performance.
+
+Use these in circumstances where it may result in more comprehensible code,
+or when you want to create custom types with restricted, immutable interfaces.
+
+For an alternative implementation designed for performance,
+please see [pyrsistent](https://github.com/tobgu/pyrsistent).
+
+### Installation
+
+Install using `pip`:
+
+ pip install itypes
+
+### Instantiating dictionaries and lists.
+
+ >>> import itypes
+ >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3})
+ >>> l = itypes.List(['a', 'b', 'c'])
+
+### On instantiation, nested types are coerced to immutables.
+
+ >>> d = itypes.Dict({'a': 123, 'b': ['a', 'b', 'c']})
+ >>> d['b']
+ List(['a', 'b', 'c'])
+
+### Assignments and deletions return new copies.
+
+Methods: `set(key, value)`, `delete(key)`
+
+ >>> d2 = d.set('c', 456)
+ >>> d2
+ Dict({'a': 123, 'b': ['a', 'b', 'c'], 'c': 456})
+ >>> d3 = d2.delete('a')
+ >>> d3
+ Dict({'b': ['a', 'b', 'c'], 'c': 456})
+
+### Standard assignments and deletions fail.
+
+ >>> d['z'] = 123
+ TypeError: 'Dict' object doesn't support item assignment
+ >>> del(d['c'])
+ TypeError: 'Dict' object doesn't support item deletion
+
+### Nested lookups.
+
+Method: `get_in(keys, default=None)`
+
+ >>> d['b'][-1]
+ 'c'
+ >>> d['b'][5]
+ IndexError: list index out of range
+ >>> d.get_in(['b', -1])
+ 'c'
+ >>> d.get_in(['b', 5])
+ None
+
+### Nested assignments and deletions.
+
+Methods: `set_in(keys, value)`, `delete_in(keys)`
+
+ >>> d2 = d.set_in(['b', 1], 'xxx')
+ >>> d2
+ Dict({'a': 123, 'b': ['a', 'xxx', 'c']})
+ >>> d3 = d2.delete_in(['b', 0])
+ >>> d3
+ Dict({'a': 123, 'b': ['xxx', 'c']})
+
+### Equality works against standard types.
+
+ >>> d = itypes.Dict({'a': 1, 'b': 2, 'c': 3})
+ >>> d == {'a': 1, 'b': 2, 'c': 3}
+ True
+
+### Objects are hashable.
+
+ >>> hash(d)
+ 277752239
+
+### Shortcuts for switching between mutable and immutable types.
+
+Functions: `to_mutable(instance)`, `to_immutable(value)`
+
+ >>> value = itypes.to_mutable(d)
+ >>> value
+ {'a': 123, 'b': ['a', 'b', 'c']}
+ >>> itypes.to_immutable(value)
+ Dict({'a': 123, 'b': ['a', 'b', 'c']})
+
+### Subclassing.
+
+Only private attribute names may be set on instances. Use `@property` for attribute access.
+
+Define a `.clone(self, data)` method if objects have additional state.
+
+Example:
+
+ class Configuration(itypes.Dict):
+ def __init__(self, title, *args, **kwargs):
+ self._title = title
+ super(Configuration, self).__init__(*args, **kwargs)
+
+ @property
+ def title(self):
+ return self._title
+
+ def clone(self, data):
+ return Configuration(self._title, data)
+
+Using the custom class:
+
+ >>> config = Configuration('worker-process', {'hostname': 'example.com', 'dynos': 4})
+ >>> config.title
+ 'worker-process'
+ >>> new = config.set('dynos', 2)
+ >>> new
+ Configuration({'dynos': 2, 'hostname': 'example.com'})
+ >>> new.title
+ 'worker-process'
+
+### Custom immutable objects.
+
+Subclass `itypes.Object` for an object that prevents setting public attributes.
+
+ >>> class Custom(itypes.Object):
+ ... pass
+
+Only private attribute names may be set on instances. Use `@property` for attribute access.
+
+ >>> class Document(itypes.Object):
+ ... def __init__(self, title, content):
+ ... self._title = title
+ ... self._content = title
+ ... @property
+ ... def title(self):
+ ... return self._title
+ ... @property
+ ... def content(self):
+ ... return self._content
+
+Using immutable objects:
+
+ >>> doc = Document(title='Immutability', content='For simplicity')
+ >>> doc.title
+ 'Immutability'
+ >>> doc.title = 'Changed'
+ TypeError: 'Document' object doesn't support property assignment.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/itypes.egg-info/PKG-INFO new/itypes-1.2.0/itypes.egg-info/PKG-INFO
--- old/itypes-1.1.0/itypes.egg-info/PKG-INFO 2016-01-07 11:58:47.000000000 +0100
+++ new/itypes-1.2.0/itypes.egg-info/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-Metadata-Version: 1.1
-Name: itypes
-Version: 1.1.0
-Summary: Simple immutable types for python.
-Home-page: http://github.com/tomchristie/itypes
-Author: Tom Christie
-Author-email: tom@tomchristie.com
-License: BSD
-Description: UNKNOWN
-Platform: UNKNOWN
-Classifier: Development Status :: 3 - Alpha
-Classifier: Environment :: Web Environment
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Topic :: Internet :: WWW/HTTP
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/itypes.egg-info/SOURCES.txt new/itypes-1.2.0/itypes.egg-info/SOURCES.txt
--- old/itypes-1.1.0/itypes.egg-info/SOURCES.txt 2016-01-07 11:58:47.000000000 +0100
+++ new/itypes-1.2.0/itypes.egg-info/SOURCES.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +0,0 @@
-itypes.py
-setup.py
-itypes.egg-info/PKG-INFO
-itypes.egg-info/SOURCES.txt
-itypes.egg-info/dependency_links.txt
-itypes.egg-info/top_level.txt
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/itypes.egg-info/dependency_links.txt new/itypes-1.2.0/itypes.egg-info/dependency_links.txt
--- old/itypes-1.1.0/itypes.egg-info/dependency_links.txt 2016-01-07 11:58:47.000000000 +0100
+++ new/itypes-1.2.0/itypes.egg-info/dependency_links.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/itypes.egg-info/top_level.txt new/itypes-1.2.0/itypes.egg-info/top_level.txt
--- old/itypes-1.1.0/itypes.egg-info/top_level.txt 2016-01-07 11:58:47.000000000 +0100
+++ new/itypes-1.2.0/itypes.egg-info/top_level.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-itypes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/itypes.py new/itypes-1.2.0/itypes.py
--- old/itypes-1.1.0/itypes.py 2016-01-07 11:58:36.000000000 +0100
+++ new/itypes-1.2.0/itypes.py 2020-04-19 23:46:35.000000000 +0200
@@ -1,8 +1,11 @@
# coding: utf-8
-from collections import Mapping, Sequence
+try:
+ from collections.abc import Mapping, Sequence
+except ImportError: # support for python 2.x
+ from collections import Mapping, Sequence
-__version__ = '1.1.0'
+__version__ = '1.2.0'
def to_mutable(instance):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/requirements.txt new/itypes-1.2.0/requirements.txt
--- old/itypes-1.1.0/requirements.txt 1970-01-01 01:00:00.000000000 +0100
+++ new/itypes-1.2.0/requirements.txt 2020-04-19 23:46:35.000000000 +0200
@@ -0,0 +1,6 @@
+# Testing requirements
+flake8
+pytest
+
+# Packaging requirements
+wheel
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/runtests new/itypes-1.2.0/runtests
--- old/itypes-1.1.0/runtests 1970-01-01 01:00:00.000000000 +0100
+++ new/itypes-1.2.0/runtests 2020-04-19 23:46:35.000000000 +0200
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+import os
+import pytest
+import subprocess
+import sys
+
+
+PYTEST_ARGS = ['tests.py', '--tb=short']
+FLAKE8_ARGS = ['itypes.py', 'tests.py', '--ignore=E501']
+COVERAGE_OPTIONS = {
+ 'include': ['itypes.py', 'tests.py'],
+}
+
+
+sys.path.append(os.path.dirname(__file__))
+
+
+class NullFile(object):
+ def write(self, data):
+ pass
+
+
+def exit_on_failure(ret, message=None):
+ if ret:
+ sys.exit(ret)
+
+
+def flake8_main(args):
+ print('Running flake8 code linting')
+ ret = subprocess.call(['flake8'] + args)
+ print('flake8 failed' if ret else 'flake8 passed')
+ return ret
+
+
+def fail_if_lacking_coverage(cov):
+ precent_covered = cov.report(
+ file=NullFile(), **COVERAGE_OPTIONS
+ )
+ if precent_covered == 100:
+ print('100% coverage')
+ return
+ print('Tests passed, but not 100% coverage.')
+ cov.report(**COVERAGE_OPTIONS)
+ cov.html_report(**COVERAGE_OPTIONS)
+ sys.exit(1)
+
+
+def split_class_and_function(string):
+ class_string, function_string = string.split('.', 1)
+ return "%s and %s" % (class_string, function_string)
+
+
+def is_function(string):
+ # `True` if it looks like a test function is included in the string.
+ return string.startswith('test_') or '.test_' in string
+
+
+def is_class(string):
+ # `True` if first character is uppercase - assume it's a class name.
+ return string[0] == string[0].upper()
+
+
+if __name__ == "__main__":
+ if len(sys.argv) > 1:
+ pytest_args = sys.argv[1:]
+ first_arg = pytest_args[0]
+ if first_arg.startswith('-'):
+ # `runtests.py [flags]`
+ pytest_args = PYTEST_ARGS + pytest_args
+ elif is_class(first_arg) and is_function(first_arg):
+ # `runtests.py TestCase.test_function [flags]`
+ expression = split_class_and_function(first_arg)
+ pytest_args = PYTEST_ARGS + ['-k', expression] + pytest_args[1:]
+ elif is_class(first_arg) or is_function(first_arg):
+ # `runtests.py TestCase [flags]`
+ # `runtests.py test_function [flags]`
+ pytest_args = PYTEST_ARGS + ['-k', pytest_args[0]] + pytest_args[1:]
+ else:
+ pytest_args = PYTEST_ARGS
+
+ # cov = coverage.coverage()
+ # cov.start()
+ exit_on_failure(pytest.main(pytest_args))
+ # cov.stop()
+ exit_on_failure(flake8_main(FLAKE8_ARGS))
+ # fail_if_lacking_coverage(cov)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/setup.cfg new/itypes-1.2.0/setup.cfg
--- old/itypes-1.1.0/setup.cfg 2016-01-07 11:58:47.000000000 +0100
+++ new/itypes-1.2.0/setup.cfg 1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-[egg_info]
-tag_build =
-tag_date = 0
-tag_svn_revision = 0
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/setup.py new/itypes-1.2.0/setup.py
--- old/itypes-1.1.0/setup.py 2015-12-23 17:32:02.000000000 +0100
+++ new/itypes-1.2.0/setup.py 2020-04-19 23:46:35.000000000 +0200
@@ -26,22 +26,36 @@
sys.exit()
+def read(fname):
+ with open(fname) as fp:
+ content = fp.read()
+ return content
+
+
setup(
name='itypes',
version=version,
- url='http://github.com/tomchristie/itypes',
+ url='http://github.com/PavanTatikonda/itypes',
license='BSD',
description='Simple immutable types for python.',
+ long_description=read('README.md'),
+ long_description_content_type="text/markdown",
author='Tom Christie',
author_email='tom@tomchristie.com',
py_modules=['itypes'],
classifiers=[
- 'Development Status :: 3 - Alpha',
+ 'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.7',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
]
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/itypes-1.1.0/tests.py new/itypes-1.2.0/tests.py
--- old/itypes-1.1.0/tests.py 1970-01-01 01:00:00.000000000 +0100
+++ new/itypes-1.2.0/tests.py 2020-04-19 23:46:35.000000000 +0200
@@ -0,0 +1,100 @@
+import itypes
+import pytest
+
+
+# [], .get()
+
+def test_dict_get():
+ orig = itypes.Dict({'a': 1, 'b': 2, 'c': 3})
+ assert orig.get('a') == 1
+ assert orig.get('z') is None
+
+
+def test_dict_lookup():
+ orig = itypes.Dict({'a': 1, 'b': 2, 'c': 3})
+ assert orig['a'] == 1
+ with pytest.raises(KeyError):
+ orig['zzz']
+
+
+def test_list_lookup():
+ orig = itypes.List(['a', 'b', 'c'])
+ assert orig[1] == 'b'
+ with pytest.raises(IndexError):
+ orig[999]
+
+
+# .delete(), .set()
+
+def test_dict_delete():
+ orig = itypes.Dict({'a': 1, 'b': 2, 'c': 3})
+ new = orig.delete('a')
+ assert new == {'b': 2, 'c': 3}
+
+
+def test_dict_set():
+ orig = itypes.Dict({'a': 1, 'b': 2, 'c': 3})
+ new = orig.set('d', 4)
+ assert new == {'a': 1, 'b': 2, 'c': 3, 'd': 4}
+
+
+def test_list_delete():
+ orig = itypes.List(['a', 'b', 'c'])
+ new = orig.delete(1)
+ assert new == ['a', 'c']
+
+
+def test_list_set():
+ orig = itypes.List(['a', 'b', 'c'])
+ new = orig.set(1, 'xxx')
+ assert new == ['a', 'xxx', 'c']
+
+
+# .get_in()
+
+def test_get_in():
+ orig = itypes.Dict({'a': ['x', 'y', 'z'], 'b': 2, 'c': 3})
+ assert orig.get_in(['a', -1]) == 'z'
+ assert orig.get_in(['dummy', -1]) is None
+ assert orig.get_in(['a', 999]) is None
+
+
+# .delete_in(), .set_in()
+
+def test_delete_in():
+ orig = itypes.Dict({'a': ['x', 'y', 'z'], 'b': 2, 'c': 3})
+ new = orig.delete_in(['a', 1])
+ assert new == {'a': ['x', 'z'], 'b': 2, 'c': 3}
+
+ orig = itypes.Dict({'a': ['x', 'y', 'z'], 'b': 2, 'c': 3})
+ new = orig.delete_in(['a'])
+ assert new == {'b': 2, 'c': 3}
+
+ orig = itypes.Dict({'a': ['x', 'y', 'z'], 'b': 2, 'c': 3})
+ new = orig.delete_in([])
+ assert new is None
+
+
+def test_set_in():
+ orig = itypes.Dict({'a': ['x', 'y', 'z'], 'b': 2, 'c': 3})
+ new = orig.set_in(['a', 1], 'yyy')
+ assert new == {'a': ['x', 'yyy', 'z'], 'b': 2, 'c': 3}
+
+ orig = itypes.Dict({'a': ['x', 'y', 'z'], 'b': 2, 'c': 3})
+ new = orig.set_in(['a'], 'yyy')
+ assert new == {'a': 'yyy', 'b': 2, 'c': 3}
+
+ orig = itypes.Dict({'a': ['x', 'y', 'z'], 'b': 2, 'c': 3})
+ new = orig.set_in([], 'yyy')
+ assert new == 'yyy'
+
+
+# Objects
+
+def test_setting_object_property():
+ class Example(itypes.Object):
+ pass
+
+ example = Example()
+ with pytest.raises(TypeError):
+ example.a = 123
++++++ itypes.obsinfo ++++++
name: itypes
version: 1.2.0
mtime: 1587332795
commit: 86b6fb6aea3546fd86eb319bd06a82a655a94a97