Hello community, here is the log from the commit of package python-pykwalify for openSUSE:Leap:15.2 checked in at 2020-03-02 13:20:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/python-pykwalify (Old) and /work/SRC/openSUSE:Leap:15.2/.python-pykwalify.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pykwalify" Mon Mar 2 13:20:58 2020 rev:11 rq:776980 version:1.7.0 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/python-pykwalify/python-pykwalify.changes 2020-01-15 15:51:59.639548059 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.python-pykwalify.new.26092/python-pykwalify.changes 2020-03-02 13:20:59.550116291 +0100 @@ -1,0 +2,27 @@ +Tue Feb 12 21:23:51 UTC 2019 - [email protected] + +- update to verison 1.7.0 (October 3, 2018) + - In this release there was a line removed from the license file. It was modified in the following commit + (cc4e31b39ff4cce2dfbc662baa6469470dd3c033 Wed Oct 3 16:20:59 2018 +0200) and will be the main reason for + the 1.7.0 release. All commits and tags and releases (1.6.1 and all releases before it) prior to this commit will + use the old license that includes the change done in the above mentioned commit. Only release 1.7.0 and commits past + this point will use the new/updated license file. + - Dropped support for python 3.3 and 3.4 + +- version 1.6.1 (March 13, 2018) + - Added support for keyword *nullable*. It is now possible to allow for a key not to be empty, when *required* keyword is not used. + - Added support for keyword *class*. It will not cause any validation errors, but serves to make kwalify schemas compatible that uses that keywork. + - Bug fixes: + - Improved compatibility with unicodes to validate as strings. + - Changed behaviour: + - Propergate json and yaml loading errors when used from the cli to the user for easier debugging. + - General changes: + - Allow ruamel.yaml versions up to 0.16 + - License is now bundled with the built release. + +------------------------------------------------------------------- +Tue Dec 4 12:52:23 UTC 2018 - Matej Cepl <[email protected]> + +- Remove superfluous devel dependency for noarch package + +------------------------------------------------------------------- Old: ---- pykwalify-1.6.0.tar.gz New: ---- pykwalify-1.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pykwalify.spec ++++++ --- /var/tmp/diff_new_pack.Hqq5Ot/_old 2020-03-02 13:20:59.930117044 +0100 +++ /var/tmp/diff_new_pack.Hqq5Ot/_new 2020-03-02 13:20:59.934117053 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-pykwalify # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -13,32 +13,32 @@ # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ +# %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without test Name: python-pykwalify -Version: 1.6.0 +Version: 1.7.0 Release: 0 -License: MIT Summary: Python lib/cli for JSON/YAML schema validation -Url: http://github.com/grokzen/pykwalify +License: MIT Group: Development/Languages/Python +Url: http://github.com/grokzen/pykwalify Source: https://files.pythonhosted.org/packages/source/p/pykwalify/pykwalify-%{version}.tar.gz -BuildRequires: python-rpm-macros -BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} +BuildRequires: python-rpm-macros %if %{with test} -BuildRequires: %{python_module docopt >= 0.6.2} -BuildRequires: %{python_module python-dateutil >= 2.4.2} BuildRequires: %{python_module PyYAML >= 3.11} +BuildRequires: %{python_module docopt >= 0.6.2} BuildRequires: %{python_module pytest} +BuildRequires: %{python_module python-dateutil >= 2.4.2} BuildRequires: %{python_module testfixtures} %endif BuildRequires: fdupes +Requires: python-PyYAML >= 3.11 Requires: python-docopt >= 0.6.2 Requires: python-python-dateutil >= 2.4.2 -Requires: python-PyYAML >= 3.11 Suggests: python-ruamel.yaml >= 0.11.0 BuildArch: noarch @@ -68,6 +68,7 @@ %files %{python_files} %defattr(-,root,root,-) %doc README.md +%license LICENSE %python3_only %{_bindir}/pykwalify %{python_sitelib}/* ++++++ pykwalify-1.6.0.tar.gz -> pykwalify-1.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/LICENSE new/pykwalify-1.7.0/LICENSE --- old/pykwalify-1.6.0/LICENSE 1970-01-01 01:00:00.000000000 +0100 +++ new/pykwalify-1.7.0/LICENSE 2018-10-03 00:36:08.000000000 +0200 @@ -0,0 +1,22 @@ +Copyright (c) 2013-2018 Johan Andersson + +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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/MANIFEST.in new/pykwalify-1.7.0/MANIFEST.in --- old/pykwalify-1.6.0/MANIFEST.in 2016-11-12 21:43:00.000000000 +0100 +++ new/pykwalify-1.7.0/MANIFEST.in 2018-03-06 15:04:10.000000000 +0100 @@ -1,9 +1,10 @@ exclude *.py -include docs/Authors.rst -include docs/License.rst +include docs/authors.rst +include docs/license.rst include docs/release-notes.rst include setup.py include README.md -exclude __pycache__ +include LICENSE +global-exclude __pycache__/* recursive-include tests * -recursive-exclude tests *.pyc +recursive-exclude tests *.py[co] \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/PKG-INFO new/pykwalify-1.7.0/PKG-INFO --- old/pykwalify-1.6.0/PKG-INFO 2017-01-22 23:35:02.000000000 +0100 +++ new/pykwalify-1.7.0/PKG-INFO 2018-10-03 17:28:53.000000000 +0200 @@ -1,22 +1,24 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: pykwalify -Version: 1.6.0 +Version: 1.7.0 Summary: Python lib/cli for JSON/YAML schema validation Home-page: http://github.com/grokzen/pykwalify Author: Johan Andersson Author-email: [email protected] +Maintainer: Johan Andersson +Maintainer-email: [email protected] License: MIT Description: # pyKwalify YAML/JSON validation library - This framework is a port with alot added functionality of the java version of the framework kwalify that can be found at: http://www.kuwata-lab.com/kwalify/ + This framework is a port with a lot of added functionality of the Java version of the framework kwalify that can be found at http://www.kuwata-lab.com/kwalify/ - The original source code can be found at: http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/ + The original source code can be found at http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/ - The source code of the latest release that has been used can be found at: https://github.com/sunaku/kwalify. Please note that source code is not the original authors code but a fork/upload of the last release available in ruby. + The source code of the latest release that has been used can be found at https://github.com/sunaku/kwalify. Please note that source code is not the original authors code but a fork/upload of the last release available in Ruby. - The schema this library is base and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema + The schema this library is based on and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema # Usage @@ -47,9 +49,9 @@ The documentation describes in detail how each keyword and type works and what is possible in each case. - But there is a lot of real world examples that can be found in the test data/files. It shows alot of examples of how all keywords and types work in practise and in combination with eachother. + But there is a lot of real world examples that can be found in the test data/files. It shows a lot of examples of how all keywords and types work in practice and in combination with each other. - The files can be found here and it shows both schema/data combinations that will work and that will fail. + The files can be found here and show both schema/data combinations that will work and that will fail. - `tests/files/success/` - `tests/files/fail/` @@ -58,7 +60,7 @@ # PyYaml and ruamel.yaml - `PyYaml` is the default installed yaml parser and `ruamel.yaml` is possible to install at the same time with the following command + `PyYaml` is the default installed YAML parser and `ruamel.yaml` is possible to install at the same time with the following command ```bash pip install 'pykwalify[ruamel]' @@ -68,30 +70,30 @@ pip install -e '.[ruamel]' ``` - `ruamel.yaml` will however be used if both is installed becuase it is more up to date and includes the YAML 1.2 specification that `PyYaml` do not support. + `ruamel.yaml` will however be used if both are installed because it is more up to date and includes the YAML 1.2 specification that `PyYaml` does not support. - `PyYaml` will still be the default parser becuase it is used more and is still considered the default `YAML` parser in the python world. + `PyYaml` will still be the default parser because it is used more and is still considered the default `YAML` parser in the Python world. - Depending on how both libraries is developed, this can change in the future in any major update. + Depending on how both libraries are developed, this can change in the future in any major update. ## UTF-8 and data encoding - If you have problems with unicode values not working properly when running pykwalify on python 2.7.x then try to add this environment variable to your execution + If you have problems with unicode values not working properly when running pykwalify on Python 2.7.x then try to add this environment variable to your execution: ``` PYTHONIOENCODING=UTF-8 pykwalify ... ``` - and it might help to force UTF-8 encoding on all string objects. If this do not work please open up a issue with your schema and data that can be used to track down the problem in the source code. + and it might help to force UTF-8 encoding on all string objects. If this does not work please open up an issue with your schema and data that can be used to track down the problem in the source code. # Project details | | | |---|---| - | python support | 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 | + | python support | 2.7, 3.5, 3.6, 3.7 | | Source | https://github.com/Grokzen/pykwalify | | Docs (Latest release) | http://pykwalify.readthedocs.io/en/master/ | | Docs (Unstable branch) | http://pykwalify.readthedocs.io/en/unstable/ | @@ -116,6 +118,44 @@ Release Notes ============= + 1.7.0 (October 3, 2018) + ----------------------- + + **IMPORTANT** LICENSE UPDATE **IMPORTANT** + + - In this release there was a line removed from the license file. It was modified in the following commit + (cc4e31b39ff4cce2dfbc662baa6469470dd3c033 Wed Oct 3 16:20:59 2018 +0200) and will be the main reason for + the 1.7.0 release. All commits and tags and releases (1.6.1 and all releases before it) prior to this commit will + use the old license that includes the change done in the above mentioned commit. Only release 1.7.0 and commits past + this point will use the new/updated license file. + + General changes: + + - Dropped support for python 3.3 and 3.4 + + + 1.6.1 (March 13, 2018) + -------------------- + + New keywords: + + - Added support for keyword *nullable*. It is now possible to allow for a key not to be empty, when *required* keyword is not used. + - Added support for keyword *class*. It will not cause any validation errors, but serves to make kwalify schemas compatible that uses that keywork. + + Bug fixes: + + - Improved compatibility with unicodes to validate as strings. + + Changed behaviour: + + - Propergate json and yaml loading errors when used from the cli to the user for easier debugging. + + General changes: + + - Allow ruamel.yaml versions up to 0.16 + - License is now bundled with the built release. + + 1.6.0 (Jan 22, 2017) -------------------- @@ -410,5 +450,8 @@ Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.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 +Description-Content-Type: text/markdown +Provides-Extra: ruamel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/README.md new/pykwalify-1.7.0/README.md --- old/pykwalify-1.6.0/README.md 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/README.md 2018-10-03 00:33:35.000000000 +0200 @@ -2,13 +2,13 @@ YAML/JSON validation library -This framework is a port with alot added functionality of the java version of the framework kwalify that can be found at: http://www.kuwata-lab.com/kwalify/ +This framework is a port with a lot of added functionality of the Java version of the framework kwalify that can be found at http://www.kuwata-lab.com/kwalify/ -The original source code can be found at: http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/ +The original source code can be found at http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/ -The source code of the latest release that has been used can be found at: https://github.com/sunaku/kwalify. Please note that source code is not the original authors code but a fork/upload of the last release available in ruby. +The source code of the latest release that has been used can be found at https://github.com/sunaku/kwalify. Please note that source code is not the original authors code but a fork/upload of the last release available in Ruby. -The schema this library is base and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema +The schema this library is based on and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema # Usage @@ -39,9 +39,9 @@ The documentation describes in detail how each keyword and type works and what is possible in each case. -But there is a lot of real world examples that can be found in the test data/files. It shows alot of examples of how all keywords and types work in practise and in combination with eachother. +But there is a lot of real world examples that can be found in the test data/files. It shows a lot of examples of how all keywords and types work in practice and in combination with each other. -The files can be found here and it shows both schema/data combinations that will work and that will fail. +The files can be found here and show both schema/data combinations that will work and that will fail. - `tests/files/success/` - `tests/files/fail/` @@ -50,7 +50,7 @@ # PyYaml and ruamel.yaml -`PyYaml` is the default installed yaml parser and `ruamel.yaml` is possible to install at the same time with the following command +`PyYaml` is the default installed YAML parser and `ruamel.yaml` is possible to install at the same time with the following command ```bash pip install 'pykwalify[ruamel]' @@ -60,30 +60,30 @@ pip install -e '.[ruamel]' ``` -`ruamel.yaml` will however be used if both is installed becuase it is more up to date and includes the YAML 1.2 specification that `PyYaml` do not support. +`ruamel.yaml` will however be used if both are installed because it is more up to date and includes the YAML 1.2 specification that `PyYaml` does not support. -`PyYaml` will still be the default parser becuase it is used more and is still considered the default `YAML` parser in the python world. +`PyYaml` will still be the default parser because it is used more and is still considered the default `YAML` parser in the Python world. -Depending on how both libraries is developed, this can change in the future in any major update. +Depending on how both libraries are developed, this can change in the future in any major update. ## UTF-8 and data encoding -If you have problems with unicode values not working properly when running pykwalify on python 2.7.x then try to add this environment variable to your execution +If you have problems with unicode values not working properly when running pykwalify on Python 2.7.x then try to add this environment variable to your execution: ``` PYTHONIOENCODING=UTF-8 pykwalify ... ``` -and it might help to force UTF-8 encoding on all string objects. If this do not work please open up a issue with your schema and data that can be used to track down the problem in the source code. +and it might help to force UTF-8 encoding on all string objects. If this does not work please open up an issue with your schema and data that can be used to track down the problem in the source code. # Project details | | | |---|---| -| python support | 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 | +| python support | 2.7, 3.5, 3.6, 3.7 | | Source | https://github.com/Grokzen/pykwalify | | Docs (Latest release) | http://pykwalify.readthedocs.io/en/master/ | | Docs (Unstable branch) | http://pykwalify.readthedocs.io/en/unstable/ | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/docs/authors.rst new/pykwalify-1.7.0/docs/authors.rst --- old/pykwalify-1.6.0/docs/authors.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/pykwalify-1.7.0/docs/authors.rst 2017-11-03 18:02:39.000000000 +0100 @@ -0,0 +1,26 @@ +Authors +======= + + +Code +---- + + - Grokzen (https://github.com/Grokzen) + - Markbaas (https://github.com/markbaas) + - Gonditeniz (https://github.com/gonditeniz) + - Comagnaw (https://github.com/comagnaw) + - Cogwirrel (https://github.com/cogwirrel) + + +Testing +------- + + - Glenn Schmottlach (https://github.com/gschmottlach-xse) + + + +Documentation +------------- + + - Grokzen (https://github.com/Grokzen) + - Scott Lowe (https://github.com/scottclowe) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/docs/license.rst new/pykwalify-1.7.0/docs/license.rst --- old/pykwalify-1.6.0/docs/license.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/pykwalify-1.7.0/docs/license.rst 2017-11-03 18:02:39.000000000 +0100 @@ -0,0 +1,6 @@ +Licensing +--------- + +MIT, See docs/License.txt for details + +Copyright (c) 2013-2017 Johan Andersson diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/docs/release-notes.rst new/pykwalify-1.7.0/docs/release-notes.rst --- old/pykwalify-1.6.0/docs/release-notes.rst 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/docs/release-notes.rst 2018-10-03 16:26:33.000000000 +0200 @@ -1,6 +1,44 @@ Release Notes ============= +1.7.0 (October 3, 2018) +----------------------- + +**IMPORTANT** LICENSE UPDATE **IMPORTANT** + +- In this release there was a line removed from the license file. It was modified in the following commit + (cc4e31b39ff4cce2dfbc662baa6469470dd3c033 Wed Oct 3 16:20:59 2018 +0200) and will be the main reason for + the 1.7.0 release. All commits and tags and releases (1.6.1 and all releases before it) prior to this commit will + use the old license that includes the change done in the above mentioned commit. Only release 1.7.0 and commits past + this point will use the new/updated license file. + +General changes: + +- Dropped support for python 3.3 and 3.4 + + +1.6.1 (March 13, 2018) +-------------------- + +New keywords: + +- Added support for keyword *nullable*. It is now possible to allow for a key not to be empty, when *required* keyword is not used. +- Added support for keyword *class*. It will not cause any validation errors, but serves to make kwalify schemas compatible that uses that keywork. + +Bug fixes: + +- Improved compatibility with unicodes to validate as strings. + +Changed behaviour: + +- Propergate json and yaml loading errors when used from the cli to the user for easier debugging. + +General changes: + +- Allow ruamel.yaml versions up to 0.16 +- License is now bundled with the built release. + + 1.6.0 (Jan 22, 2017) -------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/pykwalify/__init__.py new/pykwalify-1.7.0/pykwalify/__init__.py --- old/pykwalify-1.6.0/pykwalify/__init__.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/pykwalify/__init__.py 2018-10-03 16:29:23.000000000 +0200 @@ -8,7 +8,7 @@ import os __author__ = 'Grokzen <[email protected]>' -__version_info__ = (1, 6, 0) +__version_info__ = (1, 7, 0) __version__ = '.'.join(map(str, __version_info__)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/pykwalify/core.py new/pykwalify-1.7.0/pykwalify/core.py --- old/pykwalify-1.6.0/pykwalify/core.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/pykwalify/core.py 2018-04-30 15:32:39.000000000 +0200 @@ -67,15 +67,9 @@ with open(source_file, "r") as stream: if source_file.endswith(".json"): - try: - self.source = json.load(stream) - except Exception: - raise CoreError(u"Unable to load any data from source json file") + self.source = json.load(stream) elif source_file.endswith(".yaml") or source_file.endswith('.yml'): - try: - self.source = yaml.load(stream) - except Exception: - raise CoreError(u"Unable to load any data from source yaml file") + self.source = yaml.safe_load(stream) else: raise CoreError(u"Unable to load source_file. Unknown file format of specified file path: {0}".format(source_file)) @@ -91,12 +85,9 @@ with open(f, "r") as stream: if f.endswith(".json"): - try: - data = json.load(stream) - except Exception: - raise CoreError(u"No data loaded from file : {0}".format(f)) + data = json.load(stream) elif f.endswith(".yaml") or f.endswith(".yml"): - data = yaml.load(stream) + data = yaml.safe_load(stream) if not data: raise CoreError(u"No data loaded from file : {0}".format(f)) else: @@ -228,6 +219,14 @@ )) return + if not rule.nullable and value is None and not rule.type == 'none': + self.errors.append(SchemaError.SchemaErrorEntry( + msg=u"nullable.novalue : '{path}'", + path=path, + value=value.encode('unicode_escape') if value else value, + )) + return + log.debug(u" ? ValidateRule: %s", rule) if rule.include_name is not None: self._validate_include(value, rule, path, done=None) @@ -527,11 +526,7 @@ existing_schemas=", ".join(sorted(pykwalify.partial_schemas.keys())))) return - include_rule = Rule() - include_rule.mapping = {k: partial_schema_rule} - include_rule.regex_mappings = [] - - return self._validate(value, include_rule, u"{0}".format(path), done) + rr = partial_schema_rule # Find out if this is a regex rule is_regex_rule = False @@ -666,6 +661,7 @@ log.debug("Trimming slashes around ruby style regex. New pattern value: '{0}'".format(rule.pattern)) try: + log.debug("Matching pattern '{0}' to regex '{1}".format(rule.pattern, value)) res = re.match(rule.pattern, value, re.UNICODE) except TypeError: res = None @@ -676,6 +672,8 @@ path=path, value=nativestr(str(value)), pattern=rule._pattern)) + else: + log.debug("Pattern matched...") if rule.range is not None: if not is_scalar(value): @@ -792,7 +790,8 @@ if isinstance(date_value, str): # If a date_format is specefied then use strptime on all formats # If no date_format is specefied then use dateutils.parse() to test the value - print(date_formats) + log.debug(date_formats) + if date_formats: # Run through all date_formats and it is valid if atleast one of them passed time.strptime() parsing valid = False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/pykwalify/rule.py new/pykwalify-1.7.0/pykwalify/rule.py --- old/pykwalify-1.6.0/pykwalify/rule.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/pykwalify/rule.py 2018-03-13 22:37:29.000000000 +0100 @@ -15,6 +15,7 @@ is_builtin_type, is_collection_type, is_number, + is_string, mapping_aliases, sequence_aliases, type_class, @@ -45,6 +46,7 @@ self._matching = "any" self._matching_rule = "any" self._name = None + self._nullable = True self._parent = parent self._pattern = None self._pattern_regexp = None @@ -200,6 +202,14 @@ self._name = value @property + def nullable(self): + return self._nullable + + @nullable.setter + def nullable(self, value): + self._nullable = value + + @property def parent(self): return self._parent @@ -315,6 +325,7 @@ ('allowempty_map', 'allowempty_map'), ('assertion', 'assertion'), ('default', 'default'), + ('class', 'class'), ('desc', 'desc'), ('enum', 'enum'), ('example', 'example'), @@ -329,6 +340,7 @@ ('matching', 'matching'), ('matching_rule', 'matching_rule'), ('name', 'name'), + ('nullable', 'nullable') ('parent', 'parent'), ('pattern', 'pattern'), ('pattern_regexp', 'pattern_regexp'), @@ -380,9 +392,9 @@ t = DEFAULT_TYPE self.type = t else: - if not isinstance(schema["type"], str): + if not is_string(schema["type"]): raise RuleError( - msg=u"Key 'type' in schema rule is not a string type", + msg=u"Key 'type' in schema rule is not a string type (found %s)" % type(schema["type"]).__name__, error_key=u"type.not_string", path=path, ) @@ -398,6 +410,7 @@ func_mapping = { "allowempty": self.init_allow_empty_map, "assert": self.init_assert_value, + "class": lambda x, y, z: (), "default": self.init_default_value, "desc": self.init_desc_value, "enum": self.init_enum_value, @@ -412,6 +425,8 @@ "matching": self.init_matching, "matching-rule": self.init_matching_rule, "name": self.init_name_value, + "nul": self.init_nullable_value, + "nullable": self.init_nullable_value, "pattern": self.init_pattern_value, "range": self.init_range_value, "req": self.init_required_value, @@ -448,7 +463,7 @@ def init_format_value(self, v, rule, path): log.debug(u"Init format value : %s", path) - if isinstance(v, basestring): + if is_string(v): self._format = [v] elif isinstance(v, list): valid = True @@ -491,7 +506,7 @@ def init_example(self, v, rule, path): log.debug(u'Init example value : {0}'.format(path)) - if not isinstance(v, basestring): + if not is_string(v): raise RuleError( msg=u"Value: {0} for keyword example must be a string".format(v), error_key=u"example.not_string", @@ -636,7 +651,7 @@ def init_func(self, v, rule, path): """ """ - if not isinstance(v, str): + if not is_string(v): raise RuleError( msg=u"Value: {0} for func keyword must be a string".format(v), error_key=u"func.notstring", @@ -725,7 +740,7 @@ """ log.debug(u"Init name value : %s", path) - if not isinstance(v, basestring): + if not is_string(v): raise RuleError( msg=u"Value: {0} for keyword name must be a string".format(v), error_key=u"name.not_string", @@ -734,12 +749,26 @@ self.name = v + def init_nullable_value(self, v, rule, path): + """ + """ + log.debug(u"Init nullable value : %s", path) + + if not isinstance(v, bool): + raise RuleError( + msg=u"Value: '{0}' for nullable keyword must be a boolean".format(v), + error_key=u"nullable.not_bool", + path=path, + ) + + self.nullable = v + def init_desc_value(self, v, rule, path): """ """ log.debug(u"Init descr value : %s", path) - if not isinstance(v, basestring): + if not is_string(v): raise RuleError( msg=u"Value: {0} for keyword desc must be a string".format(v), error_key=u"desc.not_string", @@ -753,7 +782,7 @@ """ log.debug(u"Init required value : %s", path) - if not isinstance(v, bool): + if not is_bool(v): raise RuleError( msg=u"Value: '{0}' for required keyword must be a boolean".format(v), error_key=u"required.not_bool", @@ -766,7 +795,7 @@ """ log.debug(u"Init pattern value : %s", path) - if not isinstance(v, str): + if not is_string(v): raise RuleError( msg=u"Value of pattern keyword: '{0}' is not a string".format(v), error_key=u"pattern.not_string", @@ -836,7 +865,7 @@ """ log.debug(u"Init assert value : %s", path) - if not isinstance(v, str): + if not is_string(v): raise RuleError( msg=u"Value: '{0}' for keyword 'assert' is not a string".format(v), error_key=u"assert.not_str", @@ -992,7 +1021,7 @@ """ log.debug(u"Init ident value : %s", path) - if v is None or not isinstance(v, bool): + if v is None or not is_bool(v): raise RuleError( msg=u"Value: '{0}' of 'ident' is not a boolean value".format(v), error_key=u"ident.not_bool", @@ -1028,7 +1057,7 @@ """ log.debug(u"Init unique value : %s", path) - if not isinstance(v, bool): + if not is_bool(v): raise RuleError( msg=u"Value: '{0}' for 'unique' keyword is not boolean".format(v), error_key=u"unique.not_bool", @@ -1185,6 +1214,7 @@ All supported keywords: - allowempty_map - assertion + - class - date - default - desc @@ -1199,6 +1229,7 @@ - matching - matching_rule - name + - nullable - pattern - pattern_regexp - range @@ -1214,14 +1245,14 @@ if not self.strict_rule_validation: return - global_keywords = ['type', 'desc', 'example', 'extensions', 'name', 'version', 'func', 'include'] + global_keywords = ['type', 'desc', 'example', 'extensions', 'name', 'nullable', 'version', 'func', 'include'] all_allowed_keywords = { 'str': global_keywords + ['default', 'pattern', 'range', 'enum', 'required', 'unique', 'req'], 'int': global_keywords + ['default', 'range', 'enum', 'required', 'unique'], 'float': global_keywords + ['default', 'enum', 'range', 'required'], 'number': global_keywords + ['default', 'enum'], 'bool': global_keywords + ['default', 'enum'], - 'map': global_keywords + ['allowempty_map', 'mapping', 'map', 'allowempty', 'required', 'matching-rule', 'range'], + 'map': global_keywords + ['allowempty_map', 'mapping', 'map', 'allowempty', 'required', 'matching-rule', 'range', 'class'], 'seq': global_keywords + ['sequence', 'seq', 'required', 'range', 'matching'], 'sequence': global_keywords + ['sequence', 'seq', 'required'], 'mapping': global_keywords + ['mapping', 'seq', 'required'], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/pykwalify/types.py new/pykwalify-1.7.0/pykwalify/types.py --- old/pykwalify-1.6.0/pykwalify/types.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/pykwalify/types.py 2018-03-13 22:37:29.000000000 +0100 @@ -8,6 +8,16 @@ DEFAULT_TYPE = "str" + +class TextMeta(type): + def __instancecheck__(self, instance): + return is_text(instance) + + +class text(object): + __metaclass__ = TextMeta + + _types = { "str": str, "int": int, @@ -20,7 +30,7 @@ "date": datetime.date, "symbol": str, "scalar": None, - "text": None, + "text": text, "any": object, "enum": str, "none": None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/pykwalify.egg-info/PKG-INFO new/pykwalify-1.7.0/pykwalify.egg-info/PKG-INFO --- old/pykwalify-1.6.0/pykwalify.egg-info/PKG-INFO 2017-01-22 23:35:01.000000000 +0100 +++ new/pykwalify-1.7.0/pykwalify.egg-info/PKG-INFO 2018-10-03 17:28:53.000000000 +0200 @@ -1,22 +1,24 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: pykwalify -Version: 1.6.0 +Version: 1.7.0 Summary: Python lib/cli for JSON/YAML schema validation Home-page: http://github.com/grokzen/pykwalify Author: Johan Andersson Author-email: [email protected] +Maintainer: Johan Andersson +Maintainer-email: [email protected] License: MIT Description: # pyKwalify YAML/JSON validation library - This framework is a port with alot added functionality of the java version of the framework kwalify that can be found at: http://www.kuwata-lab.com/kwalify/ + This framework is a port with a lot of added functionality of the Java version of the framework kwalify that can be found at http://www.kuwata-lab.com/kwalify/ - The original source code can be found at: http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/ + The original source code can be found at http://sourceforge.net/projects/kwalify/files/kwalify-java/0.5.1/ - The source code of the latest release that has been used can be found at: https://github.com/sunaku/kwalify. Please note that source code is not the original authors code but a fork/upload of the last release available in ruby. + The source code of the latest release that has been used can be found at https://github.com/sunaku/kwalify. Please note that source code is not the original authors code but a fork/upload of the last release available in Ruby. - The schema this library is base and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema + The schema this library is based on and extended from: http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html#schema # Usage @@ -47,9 +49,9 @@ The documentation describes in detail how each keyword and type works and what is possible in each case. - But there is a lot of real world examples that can be found in the test data/files. It shows alot of examples of how all keywords and types work in practise and in combination with eachother. + But there is a lot of real world examples that can be found in the test data/files. It shows a lot of examples of how all keywords and types work in practice and in combination with each other. - The files can be found here and it shows both schema/data combinations that will work and that will fail. + The files can be found here and show both schema/data combinations that will work and that will fail. - `tests/files/success/` - `tests/files/fail/` @@ -58,7 +60,7 @@ # PyYaml and ruamel.yaml - `PyYaml` is the default installed yaml parser and `ruamel.yaml` is possible to install at the same time with the following command + `PyYaml` is the default installed YAML parser and `ruamel.yaml` is possible to install at the same time with the following command ```bash pip install 'pykwalify[ruamel]' @@ -68,30 +70,30 @@ pip install -e '.[ruamel]' ``` - `ruamel.yaml` will however be used if both is installed becuase it is more up to date and includes the YAML 1.2 specification that `PyYaml` do not support. + `ruamel.yaml` will however be used if both are installed because it is more up to date and includes the YAML 1.2 specification that `PyYaml` does not support. - `PyYaml` will still be the default parser becuase it is used more and is still considered the default `YAML` parser in the python world. + `PyYaml` will still be the default parser because it is used more and is still considered the default `YAML` parser in the Python world. - Depending on how both libraries is developed, this can change in the future in any major update. + Depending on how both libraries are developed, this can change in the future in any major update. ## UTF-8 and data encoding - If you have problems with unicode values not working properly when running pykwalify on python 2.7.x then try to add this environment variable to your execution + If you have problems with unicode values not working properly when running pykwalify on Python 2.7.x then try to add this environment variable to your execution: ``` PYTHONIOENCODING=UTF-8 pykwalify ... ``` - and it might help to force UTF-8 encoding on all string objects. If this do not work please open up a issue with your schema and data that can be used to track down the problem in the source code. + and it might help to force UTF-8 encoding on all string objects. If this does not work please open up an issue with your schema and data that can be used to track down the problem in the source code. # Project details | | | |---|---| - | python support | 2.7, 3.3, 3.4, 3.5, 3.6, 3.7 | + | python support | 2.7, 3.5, 3.6, 3.7 | | Source | https://github.com/Grokzen/pykwalify | | Docs (Latest release) | http://pykwalify.readthedocs.io/en/master/ | | Docs (Unstable branch) | http://pykwalify.readthedocs.io/en/unstable/ | @@ -116,6 +118,44 @@ Release Notes ============= + 1.7.0 (October 3, 2018) + ----------------------- + + **IMPORTANT** LICENSE UPDATE **IMPORTANT** + + - In this release there was a line removed from the license file. It was modified in the following commit + (cc4e31b39ff4cce2dfbc662baa6469470dd3c033 Wed Oct 3 16:20:59 2018 +0200) and will be the main reason for + the 1.7.0 release. All commits and tags and releases (1.6.1 and all releases before it) prior to this commit will + use the old license that includes the change done in the above mentioned commit. Only release 1.7.0 and commits past + this point will use the new/updated license file. + + General changes: + + - Dropped support for python 3.3 and 3.4 + + + 1.6.1 (March 13, 2018) + -------------------- + + New keywords: + + - Added support for keyword *nullable*. It is now possible to allow for a key not to be empty, when *required* keyword is not used. + - Added support for keyword *class*. It will not cause any validation errors, but serves to make kwalify schemas compatible that uses that keywork. + + Bug fixes: + + - Improved compatibility with unicodes to validate as strings. + + Changed behaviour: + + - Propergate json and yaml loading errors when used from the cli to the user for easier debugging. + + General changes: + + - Allow ruamel.yaml versions up to 0.16 + - License is now bundled with the built release. + + 1.6.0 (Jan 22, 2017) -------------------- @@ -410,5 +450,8 @@ Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.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 +Description-Content-Type: text/markdown +Provides-Extra: ruamel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/pykwalify.egg-info/SOURCES.txt new/pykwalify-1.7.0/pykwalify.egg-info/SOURCES.txt --- old/pykwalify-1.6.0/pykwalify.egg-info/SOURCES.txt 2017-01-22 23:35:01.000000000 +0100 +++ new/pykwalify-1.7.0/pykwalify.egg-info/SOURCES.txt 2018-10-03 17:28:53.000000000 +0200 @@ -1,7 +1,10 @@ +LICENSE MANIFEST.in README.md setup.cfg setup.py +docs/authors.rst +docs/license.rst docs/release-notes.rst pykwalify/__init__.py pykwalify/cli.py @@ -21,7 +24,6 @@ tests/test_core.py tests/test_core_methods.py tests/test_exceptions.py -tests/test_extensions.py tests/test_helper.py tests/test_rule.py tests/test_types.py @@ -46,6 +48,7 @@ tests/files/fail/test_matching.yaml tests/files/fail/test_merge.yaml tests/files/fail/test_name.yaml +tests/files/fail/test_nullable.yaml tests/files/fail/test_pattern.yaml tests/files/fail/test_range.yaml tests/files/fail/test_required.yaml @@ -87,6 +90,8 @@ tests/files/partial_schemas/5f-schema.yaml tests/files/partial_schemas/6f-data.yaml tests/files/partial_schemas/6f-schema.yaml +tests/files/partial_schemas/7s-data.yaml +tests/files/partial_schemas/7s-schema.yaml tests/files/success/test_anchor.yaml tests/files/success/test_assert.yaml tests/files/success/test_default.yaml @@ -102,6 +107,7 @@ tests/files/success/test_matching.yaml tests/files/success/test_merge.yaml tests/files/success/test_name.yaml +tests/files/success/test_nullable.yaml tests/files/success/test_pattern.yaml tests/files/success/test_range.yaml tests/files/success/test_required.yaml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/pykwalify.egg-info/requires.txt new/pykwalify-1.7.0/pykwalify.egg-info/requires.txt --- old/pykwalify-1.6.0/pykwalify.egg-info/requires.txt 2017-01-22 23:35:01.000000000 +0100 +++ new/pykwalify-1.7.0/pykwalify.egg-info/requires.txt 2018-10-03 17:28:53.000000000 +0200 @@ -3,4 +3,4 @@ python-dateutil>=2.4.2 [ruamel] -ruamel.yaml>=0.11.0,<0.12.0 +ruamel.yaml<0.16.0,>=0.11.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/setup.cfg new/pykwalify-1.7.0/setup.cfg --- old/pykwalify-1.6.0/setup.cfg 2017-01-22 23:35:02.000000000 +0100 +++ new/pykwalify-1.7.0/setup.cfg 2018-10-03 17:28:53.000000000 +0200 @@ -1,8 +1,10 @@ +[metadata] +license_file = LICENSE + [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/setup.py new/pykwalify-1.7.0/setup.py --- old/pykwalify-1.6.0/setup.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/setup.py 2018-10-03 17:26:15.000000000 +0200 @@ -11,9 +11,10 @@ setup( name="pykwalify", - version="1.6.0", + version="1.7.0", description='Python lib/cli for JSON/YAML schema validation', long_description=readme + '\n\n' + history, + long_description_content_type='text/markdown', author="Johan Andersson", author_email="[email protected]", maintainer='Johan Andersson', @@ -22,7 +23,7 @@ packages=['pykwalify'], url='http://github.com/grokzen/pykwalify', extras_require={ - 'ruamel': ["ruamel.yaml>=0.11.0,<0.12.0"], + 'ruamel': ["ruamel.yaml>=0.11.0,<0.16.0"], }, entry_points={ 'console_scripts': [ @@ -34,7 +35,7 @@ 'PyYAML>=3.11', 'python-dateutil>=2.4.2', ], - classifiers=( + classifiers=[ # 'Development Status :: 1 - Planning', # 'Development Status :: 2 - Pre-Alpha', # 'Development Status :: 3 - Alpha', @@ -49,7 +50,8 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - ) + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + ], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/files/fail/test_nullable.yaml new/pykwalify-1.7.0/tests/files/fail/test_nullable.yaml --- old/pykwalify-1.6.0/tests/files/fail/test_nullable.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/pykwalify-1.7.0/tests/files/fail/test_nullable.yaml 2018-03-13 22:37:29.000000000 +0100 @@ -0,0 +1,19 @@ +--- +name: fail-nullable-1 +desc: +data: + - name: + email: [email protected] + - email: [email protected] +schema: + type: seq + sequence: + - type: map + mapping: + name: + type: str + nullable: False + email: + type: str +errors: + - "nullable.novalue : '/0/name'" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/files/partial_schemas/7s-data.yaml new/pykwalify-1.7.0/tests/files/partial_schemas/7s-data.yaml --- old/pykwalify-1.6.0/tests/files/partial_schemas/7s-data.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/pykwalify-1.7.0/tests/files/partial_schemas/7s-data.yaml 2018-02-06 15:49:42.000000000 +0100 @@ -0,0 +1,5 @@ +foo: blah +bar: + - blah + - blah + - blah diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/files/partial_schemas/7s-schema.yaml new/pykwalify-1.7.0/tests/files/partial_schemas/7s-schema.yaml --- old/pykwalify-1.6.0/tests/files/partial_schemas/7s-schema.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/pykwalify-1.7.0/tests/files/partial_schemas/7s-schema.yaml 2018-02-06 15:54:34.000000000 +0100 @@ -0,0 +1,12 @@ +type: map +mapping: + foo: + type: str + required: True + bar: + include: bar +schema;bar: + type: seq + required: True + sequence: + - type: str diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/files/success/test_nullable.yaml new/pykwalify-1.7.0/tests/files/success/test_nullable.yaml --- old/pykwalify-1.6.0/tests/files/success/test_nullable.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/pykwalify-1.7.0/tests/files/success/test_nullable.yaml 2018-03-13 22:37:29.000000000 +0100 @@ -0,0 +1,11 @@ +--- +name: nullable1 +desc: Test that nullable works +data: + name: +schema: + type: map + mapping: + name: + type: str + nullable: True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/test_core.py new/pykwalify-1.7.0/tests/test_core.py --- old/pykwalify-1.6.0/tests/test_core.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/tests/test_core.py 2018-06-08 19:45:26.000000000 +0200 @@ -121,9 +121,12 @@ schema_f = tmpdir.join("bar.json") schema_f.write("") - with pytest.raises(CoreError) as ex: + with pytest.raises(ValueError) as ex: Core(source_file=str(source_f), schema_files=[str(schema_f)]) - assert "Unable to load any data from source json file" in str(ex.value) + # Python 2.7 and Python 3.5 JSON parsers return different exception + # strings for the same data file, so check for both errors strings. + assert ("No JSON object could be decoded" in str(ex.value) or + "Expecting value:" in str(ex.value)) # Load empty schema files source_f = tmpdir.join("foo.json") @@ -132,9 +135,10 @@ schema_f = tmpdir.join("bar.json") schema_f.write("") - with pytest.raises(CoreError) as ex: + with pytest.raises(ValueError) as ex: Core(source_file=str(source_f), schema_files=[str(schema_f)]) - assert "No data loaded from file" in str(ex.value) + assert ("No JSON object could be decoded" in str(ex.value) or + "Expecting value:" in str(ex.value)) def test_load_empty_yaml_file(self, tmpdir): """ @@ -244,6 +248,25 @@ 'sequence': [{'include': 'fooone'}], 'type': 'seq', } + ), + # This tests that you can include a partial schema alongside other rules in a map + ( + [ + self.f("partial_schemas", "7s-schema.yaml"), + ], + self.f("partial_schemas", "7s-data.yaml"), + { + 'type': 'map', + 'mapping': { + 'foo': { + 'type': 'str', + 'required': True + }, + 'bar': { + 'include': 'bar' + } + } + } ) ] @@ -256,7 +279,7 @@ ], self.f("partial_schemas", "1f-data.yaml"), SchemaError, - ["Cannot find partial schema with name 'fooonez'. Existing partial schemas: 'fooone, foothree, footwo'. Path: '/0'"] + ["Cannot find partial schema with name 'fooonez'. Existing partial schemas: 'bar, fooone, foothree, footwo'. Path: '/0'"] ), ( [ @@ -313,7 +336,7 @@ compare(c.root_rule.schema_str, passing_test[2], prefix="Parsed rules is not correct, something have changed...") for failing_test in failing_tests: - with pytest.raises(failing_test[2], msg="Test files: {0} : {1}".format(", ".join(failing_test[0]), failing_test[1])): + with pytest.raises(failing_test[2], message="Test files: {0} : {1}".format(", ".join(failing_test[0]), failing_test[1])): c = Core(schema_files=failing_test[0], source_file=failing_test[1]) c.validate() @@ -358,6 +381,8 @@ "test_matching.yaml", # All tests for keyword name "test_name.yaml", + # All tests for keyword nullable + "test_nullable.yaml", # All tests for keyword pattern "test_pattern.yaml", # All tests for keyword range @@ -439,6 +464,8 @@ ("test_matching.yaml", SchemaError), # All tests for keyword name ("test_name.yaml", SchemaError), + # All tests for keyword nullable + ("test_nullable.yaml", SchemaError), # All tests for keyword pattern ("test_pattern.yaml", SchemaError), # All tests for keyword range @@ -502,7 +529,7 @@ for passing_test_file in pass_tests: f = self.f(os.path.join("success", passing_test_file)) with open(f, "r") as stream: - yaml_data = yaml.load_all(stream) + yaml_data = yaml.safe_load_all(stream) for document_index, document in enumerate(yaml_data): data = document["data"] @@ -523,7 +550,7 @@ for failing_test, exception_type in _fail_tests: f = self.f(os.path.join("fail", failing_test)) with open(f, "r") as stream: - yaml_data = yaml.load_all(stream) + yaml_data = yaml.safe_load_all(stream) for document_index, document in enumerate(yaml_data): data = document["data"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/test_extensions.py new/pykwalify-1.7.0/tests/test_extensions.py --- old/pykwalify-1.6.0/tests/test_extensions.py 2015-08-03 15:05:06.000000000 +0200 +++ new/pykwalify-1.7.0/tests/test_extensions.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -""" Unit test for pyKwalify - extensions """ - -# python std lib -import os - -# pykwalify imports -import pykwalify - - -class TestExtensions(object): - - def setUp(self): - pykwalify.partial_schemas = {} - - def f(self, *args): - return os.path.join(os.path.dirname(os.path.realpath(__file__)), "files", "extensions", *args) - - def test_(self, tmpdir): - """ - """ - pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/test_rule.py new/pykwalify-1.7.0/tests/test_rule.py --- old/pykwalify-1.6.0/tests/test_rule.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/tests/test_rule.py 2018-03-13 22:37:29.000000000 +0100 @@ -12,6 +12,7 @@ import pykwalify from pykwalify.errors import RuleError, SchemaConflict from pykwalify.rule import Rule +from pykwalify.compat import unicode class TestRule(unittest.TestCase): @@ -52,16 +53,20 @@ # assert str(r.value) == "<RuleError: error code 4: Key 'type' not found in schema rule: Path: '/'>" # assert r.value.error_key == 'type.missing' + # Test a valid rule with both "str" and "unicode" types work + r = Rule(schema={"type": str("str")}) + r = Rule(schema={"type": unicode("str")}) + # Test that type key must be string otherwise exception is raised with pytest.raises(RuleError) as r: Rule(schema={"type": 1}) - assert str(r.value) == "<RuleError: error code 4: Key 'type' in schema rule is not a string type: Path: '/'>" + assert str(r.value) == "<RuleError: error code 4: Key 'type' in schema rule is not a string type (found int): Path: '/'>" assert r.value.error_key == 'type.not_string' # this tests that the type key must be a string with pytest.raises(RuleError) as r: Rule(schema={"type": 1}, parent=None) - assert str(r.value) == "<RuleError: error code 4: Key 'type' in schema rule is not a string type: Path: '/'>" + assert str(r.value) == "<RuleError: error code 4: Key 'type' in schema rule is not a string type (found int): Path: '/'>" assert r.value.error_key == 'type.not_string' def test_name_value(self): @@ -69,6 +74,13 @@ Rule(schema={'type': 'str', 'name': {}}) assert str(r.value) == "<RuleError: error code 4: Value: {} for keyword name must be a string: Path: '/'>" + def test_nullable_value(self): + # Test that nullable value must be bool otherwise exception is raised + with pytest.raises(RuleError) as r: + Rule(schema={"type": "str", "nullable": "foobar"}) + assert str(r.value) == "<RuleError: error code 4: Value: 'foobar' for nullable keyword must be a boolean: Path: '/'>" + assert r.value.error_key == 'nullable.not_bool' + def test_desc_value(self): with pytest.raises(RuleError) as r: Rule(schema={'type': 'str', 'desc': []}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pykwalify-1.6.0/tests/test_unicode.py new/pykwalify-1.7.0/tests/test_unicode.py --- old/pykwalify-1.6.0/tests/test_unicode.py 2017-01-22 23:34:12.000000000 +0100 +++ new/pykwalify-1.7.0/tests/test_unicode.py 2018-02-06 20:25:16.000000000 +0100 @@ -65,7 +65,7 @@ f = self.f(passing_test_files) with open(f, "r") as stream: - yaml_data = yaml.load(stream) + yaml_data = yaml.safe_load(stream) data = yaml_data["data"] schema = yaml_data["schema"] @@ -120,7 +120,7 @@ f = self.f(failing_test) with open(f, "r") as stream: - yaml_data = yaml.load(stream) + yaml_data = yaml.safe_load(stream) data = yaml_data["data"] schema = yaml_data["schema"] errors = yaml_data["errors"]
