Merge staging-next into staging

This commit is contained in:
Frederik Rietdijk
2018-12-07 15:31:52 +01:00
225 changed files with 5366 additions and 4074 deletions

View File

@@ -1,13 +1,12 @@
{ gui ? true,
buildPythonPackage, fetchFromGitHub, lib,
sphinx_1_2, lxml, isodate, numpy, pytest,
tkinter ? null, py3to2, isPy3k,
sphinx, lxml, isodate, numpy, pytest, openpyxl,
tkinter ? null, py3to2, isPy3k, python,
... }:
buildPythonPackage rec {
pname = "arelle-${version}${lib.optionalString (!gui) "-headless"}";
version = "2017-08-24";
name = pname + "-" + version;
pname = "arelle${lib.optionalString (!gui) "-headless"}";
version = "18.3";
disabled = !isPy3k;
@@ -16,8 +15,8 @@ buildPythonPackage rec {
src = fetchFromGitHub {
owner = "Arelle";
repo = "Arelle";
rev = "cb24e35d57b562a864ae3dd4542c4d9fcf3865fe";
sha256 = "1sbvhb3xlfnyvf1xj9dxwpcrfiaf7ikkdwvvap7aaxfxgiz85ip2";
rev = "edgr${version}";
sha256 = "12a94ipdp6xalqyds7rcp6cjwps6fbj3byigzfy403hlqc9n1g33";
};
outputs = ["out" "doc"];
patches = [
@@ -25,7 +24,7 @@ buildPythonPackage rec {
];
postPatch = "rm testParser2.py";
buildInputs = [
sphinx_1_2
sphinx
pytest
py3to2
];
@@ -33,6 +32,7 @@ buildPythonPackage rec {
lxml
isodate
numpy
openpyxl
] ++ lib.optional gui [
tkinter
];
@@ -40,6 +40,12 @@ buildPythonPackage rec {
# arelle-gui is useless without gui dependencies, so delete it when !gui.
postInstall = lib.optionalString (!gui) ''
find $out/bin -name "*arelle-gui*" -delete
'' +
# By default, not the entirety of the src dir is copied. This means we don't
# copy the `images` dir, which is needed for the gui version.
lib.optionalString (gui) ''
targetDir=$out/${python.sitePackages}
cp -vr $src/arelle $targetDir
'';
# Documentation
@@ -49,11 +55,14 @@ buildPythonPackage rec {
doCheck = if gui then true else false;
meta = {
description = "An open source facility for XBRL, the eXtensible Business Reporting Language supporting various standards, exposed through a python or REST API" + lib.optionalString gui " and a graphical user interface";
meta = with lib; {
description = ''
An open source facility for XBRL, the eXtensible Business Reporting
Language supporting various standards, exposed through a Python or
REST API'' + lib.optionalString gui " and a graphical user interface";
homepage = http://arelle.org/;
license = lib.licenses.asl20;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ roberth ];
license = licenses.asl20;
platforms = platforms.all;
maintainers = with maintainers; [ roberth ];
};
}

View File

@@ -3,7 +3,7 @@ index a64bb1b..dc0299d 100644
--- c/arelle/CntlrProfiler.py
+++ i/arelle/CntlrProfiler.py
@@ -1,5 +1,6 @@
-import Cntlr, ModelManager, FileSource, time
+from arelle import Cntlr, ModelManager, FileSource
+import time
@@ -12,21 +12,3 @@ index a64bb1b..dc0299d 100644
import gettext
diff --git c/arelle/ValidateFilingText.py i/arelle/ValidateFilingText.py
index 12dbbbb..c0e98c3 100644
--- c/arelle/ValidateFilingText.py
+++ i/arelle/ValidateFilingText.py
@@ -16,7 +16,7 @@ XMLdeclaration = re.compile(r"<\?xml.*\?>", re.DOTALL)
XMLpattern = re.compile(r".*(<|&lt;|&#x3C;|&#60;)[A-Za-z_]+[A-Za-z0-9_:]*[^>]*(/>|>|&gt;|/&gt;).*", re.DOTALL)
CDATApattern = re.compile(r"<!\[CDATA\[(.+)\]\]")
#EFM table 5-1 and all &xxx; patterns
-docCheckPattern = re.compile(r"&\w+;|[^0-9A-Za-z`~!@#$%&\*\(\)\.\-+ \[\]\{\}\|\\:;\"'<>,_?/=\t\n\r\m\f]") # won't match &#nnn;
+docCheckPattern = re.compile(r"&\w+;|[^0-9A-Za-z`~!@#$%&\*\(\)\.\-+ \[\]\{\}\|\\:;\"'<>,_?/=\t\n\r\f]") # won't match &#nnn;
namedEntityPattern = re.compile("&[_A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]"
r"[_\-\.:"
"\xB7A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u0300-\u036F\u203F-\u2040]*;")
@@ -904,4 +904,4 @@ def referencedFiles(modelXbrl, localFilesOnly=True):
# footnote or other elements
for elt in modelXbrl.modelDocument.xmlRootElement.iter("{http://www.w3.org/1999/xhtml}a", "{http://www.w3.org/1999/xhtml}img"):
addReferencedFile(elt, elt)
- return referencedFiles
\ No newline at end of file
+ return referencedFiles

View File

@@ -5,13 +5,13 @@
buildPythonPackage rec {
pname = "astroid";
version = "2.0.4";
version = "2.1.0";
disabled = pythonOlder "3.4";
src = fetchPypi {
inherit pname version;
sha256 = "c7013d119ec95eb626f7a2011f0b63d0c9a095df9ad06d8507b37084eada1a8d";
sha256 = "08hz675knh4294bancdapql392fmbjyimhbyrmfkz1ka7l035c1m";
};
# From astroid/__pkginfo__.py

View File

@@ -1,4 +1,4 @@
{ stdenv, buildPythonPackage, fetchPypi, isPy3k
{ stdenv, buildPythonPackage, fetchPypi, isPy3k, fetchpatch
, cairocffi, cssselect2, defusedxml, pillow, tinycss2
, pytestrunner, pytestcov, pytest-flake8, pytest-isort }:
@@ -13,6 +13,16 @@ buildPythonPackage rec {
sha256 = "93c5b3204478c4e20c4baeb33807db5311b4420c21db2f21034a6deda998cb14";
};
patches = [
# Fix tests. Remove with the next release
(fetchpatch {
url = https://github.com/Kozea/CairoSVG/commit/1f403ad229f0e2782d6427a79f0fbeb6b76148b6.patch;
sha256 = "1dxpj5zh8wmx9f8pj11hrixd5jlaqq5xlcdnbl462bh29zj18l26";
})
];
LC_ALL="en_US.UTF-8";
propagatedBuildInputs = [ cairocffi cssselect2 defusedxml pillow tinycss2 ];
checkInputs = [ pytestrunner pytestcov pytest-flake8 pytest-isort ];

View File

@@ -1,4 +1,4 @@
{ stdenv, buildPythonPackage, fetchPypi, blessings, mock, nose, pyte, wcwidth, typing }:
{ stdenv, buildPythonPackage, fetchPypi, fetchpatch, pythonOlder, blessings, mock, nose, pyte, wcwidth, typing }:
buildPythonPackage rec {
pname = "curtsies";
@@ -8,7 +8,16 @@ buildPythonPackage rec {
sha256 = "89c802ec051d01dec6fc983e9856a3706e4ea8265d2940b1f6d504a9e26ed3a9";
};
propagatedBuildInputs = [ blessings wcwidth typing ];
patches = [
# Fix dependency on typing. Remove with the next release
(fetchpatch {
url = https://github.com/bpython/curtsies/commit/217b4f83e954837f8adc4c549c1f2f9f2bb272a7.patch;
sha256 = "1d3zwx9c7i0drb4nvydalm9mr83jrvdm75ffgisri89h337hiffs";
})
];
propagatedBuildInputs = [ blessings wcwidth ]
++ stdenv.lib.optionals (pythonOlder "3.5") [ typing ];
checkInputs = [ mock pyte nose ];
@@ -18,7 +27,7 @@ buildPythonPackage rec {
meta = with stdenv.lib; {
description = "Curses-like terminal wrapper, with colored strings!";
homepage = https://pypi.python.org/pypi/curtsies;
homepage = https://github.com/bpython/curtsies;
license = licenses.mit;
maintainers = with maintainers; [ flokli ];
};

View File

@@ -1,14 +0,0 @@
--- a/setup.py 2014-02-04 16:12:37.021993713 +0100
+++ b/setup.py 2014-02-04 16:11:42.653995607 +0100
@@ -13,8 +13,8 @@
package_dir = {'': 'src'},
packages = ['fedpkg'],
scripts = ['src/bin/fedpkg'],
- data_files = [('/etc/bash_completion.d', ['src/fedpkg.bash']),
- ('/etc/rpkg', ['src/fedpkg.conf']),
- ('/usr/libexec/', ['src/fedpkg-fixbranches.py']),
+ data_files = [('etc/bash_completion.d', ['src/fedpkg.bash']),
+ ('etc/rpkg', ['src/fedpkg.conf']),
+ ('libexec/', ['src/fedpkg-fixbranches.py']),
]
)

View File

@@ -1,26 +0,0 @@
{ stdenv, buildPythonPackage, isPy3k, fetchurl, rpkg, offtrac, urlgrabber }:
buildPythonPackage rec {
pname = "fedpkg";
version = "1.29";
name = "${pname}-${version}";
disabled = isPy3k;
src = fetchurl {
url = "https://releases.pagure.org/fedpkg/${name}.tar.bz2";
sha256 = "1cpy5p1rp7w52ighz3ynvhyw04z86y8phq3n8563lj6ayr8pw631";
};
#patches = [ ../development/python-modules/fedpkg-buildfix.diff ];
propagatedBuildInputs = [ rpkg offtrac urlgrabber ];
doCheck = false; # requires fedora_cert which isn't used anymore
meta = with stdenv.lib; {
description = "Subclass of the rpkg project for dealing with rpm packaging";
homepage = https://pagure.io/fedpkg;
license = licenses.gpl2;
maintainers = with maintainers; [ ];
};
}

View File

@@ -1,4 +1,4 @@
{ lib, fetchFromGitHub, buildPythonPackage, flake8, six }:
{ lib, fetchFromGitHub, buildPythonPackage, fetchpatch, flake8, six }:
buildPythonPackage rec {
pname = "flake8-future-import";
@@ -12,6 +12,14 @@ buildPythonPackage rec {
sha256 = "00fpxa6g8cabybnciwnpsbg60zhgydc966jgwyyggw1pcg0frdqr";
};
patches = [
# Add Python 3.7 support. Remove with the next release
(fetchpatch {
url = https://github.com/xZise/flake8-future-import/commit/cace194a44d3b95c9c1ed96640bae49183acca04.patch;
sha256 = "17pkqnh035j5s5c53afs8bk49bq7lnmdwqp5k7izx7sw80z73p9r";
})
];
propagatedBuildInputs = [ flake8 six ];
meta = {

View File

@@ -1,15 +1,13 @@
{ stdenv, buildPythonPackage, fetchFromGitHub, pythonAtLeast
{ stdenv, buildPythonPackage, fetchPypi, pythonAtLeast
, flask, blinker, nose, mock, semantic-version }:
buildPythonPackage rec {
pname = "Flask-Login";
version = "0.4.1";
src = fetchFromGitHub {
owner = "maxcountryman";
repo = "flask-login";
rev = version;
sha256 = "1rj0qwyxapxnp84fi4lhmvh3d91fdiwz7hibw77x3d5i72knqaa9";
src = fetchPypi {
inherit pname version;
sha256 = "1v2j8zd558xfmgn3rfbw0xz4vizjcnk8kqw52q4f4d9ygfnc25f8";
};
checkInputs = [ nose mock semantic-version ];

View File

@@ -1,22 +1,21 @@
{ stdenv
, buildPythonPackage
, fetchFromGitHub
, fetchPypi
, nose
, six
}:
buildPythonPackage rec {
version = "0.7.0";
version = "0.8.1";
pname = "parsimonious";
src = fetchFromGitHub {
repo = "parsimonious";
owner = "erikrose";
rev = version;
sha256 = "087npc8ccryrxabmqifcz56w4wd0hzmv0mc91wrbhc1sil196j0a";
src = fetchPypi {
inherit pname version;
sha256 = "3add338892d580e0cb3b1a39e4a1b427ff9f687858fdd61097053742391a9f6b";
};
propagatedBuildInputs = [ nose six ];
checkInputs = [ nose ];
propagatedBuildInputs = [ six ];
meta = with stdenv.lib; {
homepage = "https://github.com/erikrose/parsimonious";

View File

@@ -13,8 +13,18 @@ buildPythonPackage rec {
buildInputs = [ doctest-ignore-unicode mock nose ];
propagatedBuildInputs = [ graphviz pkgconfig ];
# the tests are currently failing:
# check status of pygraphviz/pygraphviz#129
patches = [
# pygraphviz depends on graphviz being in PATH. This patch always prepends
# graphviz to PATH.
./graphviz-path.patch
];
postPatch = ''
substituteInPlace pygraphviz/agraph.py --subst-var-by graphvizPath '${graphviz}/bin'
'';
# The tests are currently failing because of a bug in graphviz 2.40.1.
# Upstream does not want to skip the relevant tests:
# https://github.com/pygraphviz/pygraphviz/pull/129
doCheck = false;
meta = with stdenv.lib; {

View File

@@ -0,0 +1,13 @@
diff --git a/pygraphviz/agraph.py b/pygraphviz/agraph.py
index 8f72024..2d8358e 100644
--- a/pygraphviz/agraph.py
+++ b/pygraphviz/agraph.py
@@ -1557,7 +1557,7 @@ class AGraph(object):
import os
import glob
- paths = os.environ["PATH"]
+ paths = '@graphvizPath@:' + os.environ["PATH"]
if os.name == "nt":
exe = ".exe"
else:

View File

@@ -1,6 +1,6 @@
{ lib, buildPythonPackage, fetchPypi
, cryptography, ecdsa
, pytestrunner, pytestcov, pytest_37 }:
, pytestrunner, pytestcov, pytest }:
buildPythonPackage rec {
pname = "PyJWT";
@@ -13,7 +13,7 @@ buildPythonPackage rec {
propagatedBuildInputs = [ cryptography ecdsa ];
checkInputs = [ pytestrunner pytestcov pytest_37 ];
checkInputs = [ pytestrunner pytestcov pytest ];
# pytest 3.9.0 changed behavior of deprecated_call, see release notes
postPatch = ''

View File

@@ -1,4 +1,4 @@
{ lib, buildPythonPackage, fetchPypi, fontconfig, python, freefont_ttf, makeFontsConf }:
{ lib, buildPythonPackage, fetchPypi, fontconfig, python, cython, freefont_ttf, makeFontsConf }:
let
fontsConf = makeFontsConf {
@@ -14,6 +14,11 @@ in buildPythonPackage rec {
};
buildInputs = [ fontconfig ];
nativeBuildInputs = [ cython ];
preBuild = ''
${python.interpreter} setup.py build_ext -i
'';
checkPhase = ''
export FONTCONFIG_FILE=${fontsConf};

View File

@@ -1,50 +1,57 @@
{ stdenv, buildPythonPackage, fetchFromGitHub, libxml2
, m2crypto, ply, pyyaml, six
, httpretty, lxml, mock, pytest, requests
{ lib, buildPythonPackage, fetchPypi, libxml2
, m2crypto, ply, pyyaml, six, pbr, pythonOlder, isPy37, python
, httpretty, lxml, mock, pytest, requests, decorator, unittest2
}:
buildPythonPackage rec {
pname = "pywbem";
version = "0.10.0";
version = "0.12.6";
src = fetchFromGitHub {
owner = "pywbem";
repo = "pywbem";
rev = "v${version}";
sha256 = "0jcwklip03xcni0dvsk9va8ilqz21g4fxwqd5kzvv91slaadfcym";
# Support added in master https://github.com/pywbem/pywbem/commit/b2f2f1a151a30355bbc6652dca69a7b30bfe941e awaiting release
disabled = isPy37;
src = fetchPypi {
inherit pname version;
sha256 = "1dc6b745rrys600n05apdf6lb2vv5arlcwv7aiz9whgkbcd9qhki";
};
patches = [
# fix timezone handling so the tests pass again. Can go when 0.10.1 is released
# https://github.com/pywbem/pywbem/issues/755#issuecomment-327508681
./make_cimdatetime_timezone_aware.patch
propagatedBuildInputs = [
mock
pbr
ply
pyyaml
six
] ++ lib.optionals (pythonOlder "3.0") [ m2crypto ];
checkInputs = [
decorator
httpretty
libxml2
lxml
pytest
requests
unittest2
];
propagatedBuildInputs = [ m2crypto ply pyyaml six ];
postPatch = ''
# Uses deprecated library yamlordereddictloader
rm testsuite/test_client.py
checkInputs = [ httpretty lxml mock pytest requests ];
# 1 test fails because it doesn't like running in our sandbox. Deleting the
# whole file is admittedly a little heavy-handed but at least the vast
# majority of tests are run.
checkPhase = ''
rm testsuite/testclient/networkerror.yaml
substituteInPlace makefile \
--replace "PYTHONPATH=." "" \
--replace '--cov $(package_name) --cov-config coveragerc' ""
for f in testsuite/test_cim_xml.py testsuite/validate.py ; do
substituteInPlace $f --replace "'xmllint" "'${stdenv.lib.getBin libxml2}/bin/xmllint"
done
make PATH=$PATH:${stdenv.lib.getBin libxml2}/bin test
# Wants `wbemcli` in PATH
rm testsuite/test_wbemcli.py
# Disables tests that use testfixtures which is currently broken by nonbuilding zope_component
rm testsuite/{test_logging,test_recorder,test_wbemconnection_mock}.*
'';
meta = with stdenv.lib; {
description = "Support for the WBEM standard for systems management.";
homepage = http://pywbem.github.io/pywbem/;
license = licenses.gpl2;
checkPhase = ''
pytest testsuite/
'';
meta = with lib; {
description = "Support for the WBEM standard for systems management";
homepage = https://pywbem.github.io;
license = licenses.lgpl21Plus;
maintainers = with maintainers; [ peterhoeg ];
};
}

View File

@@ -1,491 +0,0 @@
From bb7fa19d636d999bf844d80939e155b8f212ef3e Mon Sep 17 00:00:00 2001
From: Andreas Maier <maiera@de.ibm.com>
Date: Fri, 23 Jun 2017 19:13:51 +0200
Subject: [PATCH] Made CIMDateTime always timezone-aware, re-enabled
test_cim_types.py
Details:
- Ensured that 'CIMDateTime' objects for point in time values are
timezone-aware when supplied with a timezone-naive 'datetime'
object. This does not change the behavior, but increases code
clarity.
- Clarified that in the documentation of 'CIMDateTime'.
- Added testcases for CIMDateTime.
- Re-enabled the testing of test_cim_types.py. Since its change
to using pytest it was not run because the test methods were
all static methods which apparently does not work. Not sure
this ever worked.
Signed-off-by: Andreas Maier <maiera@de.ibm.com>
---
docs/changes.rst | 5 +
pywbem/cim_types.py | 22 +--
testsuite/test_cim_types.py | 369 +++++++++++++++++++++++---------------------
3 files changed, 207 insertions(+), 189 deletions(-)
diff --git a/docs/changes.rst b/docs/changes.rst
index 272ed30d..6fdfbcf4 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -72,6 +72,11 @@ Enhancements
* Added unit test for recorder. See issue #676
+* Ensured that `CIMDateTime` objects for point in time values are
+ timezone-aware when supplied with a timezone-naive `datetime` object.
+ This does not change the behavior, but increases code clarity.
+ Clarified that in the documentation of `CIMDateTime`. See issue #698.
+
Bug fixes
^^^^^^^^^
diff --git a/pywbem/cim_types.py b/pywbem/cim_types.py
index 6d1f140c..5ecc7707 100644
--- a/pywbem/cim_types.py
+++ b/pywbem/cim_types.py
@@ -74,6 +74,7 @@
import re
import warnings
import six
+import copy
from . import config
@@ -294,9 +295,11 @@ def __init__(self, dtarg):
* A :term:`string` object will be
interpreted as CIM datetime format (see :term:`DSP0004`) and
will result in a point in time or a time interval.
- * A :class:`py:datetime.datetime` object must be timezone-aware
- (see :class:`~pywbem.MinutesFromUTC`) and will result in a point
- in time.
+ * A :class:`py:datetime.datetime` object will result in a point
+ in time. If the :class:`py:datetime.datetime` object is
+ timezone-aware (see :class:`~pywbem.MinutesFromUTC`), the
+ specified timezone will be used. Otherwise, a default timezone
+ of UTC will be assumed.
* A :class:`py:datetime.timedelta` object will result in a time
interval.
* Another :class:`~pywbem.CIMDateTime` object will be copied.
@@ -342,14 +345,15 @@ def __init__(self, dtarg):
raise ValueError('dtarg argument "%s" has an invalid CIM '
'datetime format' % dtarg)
elif isinstance(dtarg, datetime):
- self.__datetime = dtarg
+ if dtarg.tzinfo is None:
+ self.__datetime = dtarg.replace(tzinfo=MinutesFromUTC(0))
+ else:
+ self.__datetime = copy.copy(dtarg)
elif isinstance(dtarg, timedelta):
- self.__timedelta = dtarg
+ self.__timedelta = copy.copy(dtarg)
elif isinstance(dtarg, CIMDateTime):
- # pylint: disable=protected-access
- self.__datetime = dtarg.__datetime
- # pylint: disable=protected-access
- self.__timedelta = dtarg.__timedelta
+ self.__datetime = copy.copy(dtarg.datetime)
+ self.__timedelta = copy.copy(dtarg.timedelta)
else:
raise TypeError('dtarg argument "%s" has an invalid type: %s '
'(expected datetime, timedelta, string, or '
diff --git a/testsuite/test_cim_types.py b/testsuite/test_cim_types.py
index 4ae354d3..b1f54d06 100755
--- a/testsuite/test_cim_types.py
+++ b/testsuite/test_cim_types.py
@@ -43,105 +43,99 @@ def integer_tuple(request):
return request.param
-class TestIntegers:
- """
- Test CIM integer data type classes.
- """
-
- @staticmethod
- def test_class_attrs_class(integer_tuple):
- """Test class attrs via class level"""
- obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
- assert obj_type.cimtype == exp_cimtype
- assert obj_type.minvalue == exp_minvalue
- assert obj_type.maxvalue == exp_maxvalue
-
- @staticmethod
- def test_class_attrs_inst(integer_tuple):
- """Test class attrs via instance level"""
- obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
- obj = obj_type(42)
- assert obj.cimtype == exp_cimtype
- assert obj.minvalue == exp_minvalue
- assert obj.maxvalue == exp_maxvalue
-
- @staticmethod
- def test_inheritance(integer_tuple):
- """Test inheritance"""
- obj_type = integer_tuple[0]
- obj = obj_type(42)
- assert isinstance(obj, obj_type)
- assert isinstance(obj, CIMType)
- assert isinstance(obj, CIMInt)
- assert not isinstance(obj, CIMFloat)
-
- @staticmethod
- def test_init_int(integer_tuple):
- """Test initialization from integer value"""
- obj_type = integer_tuple[0]
- obj = obj_type(42)
- assert obj == 42
-
- @staticmethod
- def test_init_str(integer_tuple):
- """Test initialization from string value"""
- obj_type = integer_tuple[0]
- obj = obj_type('42')
- assert obj == 42
-
- @staticmethod
- def test_init_str_base10(integer_tuple):
- """Test initialization from string value with base 10"""
- obj_type = integer_tuple[0]
- obj = obj_type('42', 10)
- assert obj == 42
-
- @staticmethod
- def test_init_str_base16(integer_tuple):
- """Test initialization from string value with base 16"""
- obj_type = integer_tuple[0]
- obj = obj_type('2A', 16)
- assert obj == 42
-
- @staticmethod
- def test_init_minimum(integer_tuple):
- """Test initialization from integer value at minimum"""
- obj_type = integer_tuple[0]
- exp_minvalue = integer_tuple[2]
- obj = obj_type(exp_minvalue)
- assert obj == exp_minvalue
-
- @staticmethod
- def test_init_maximum(integer_tuple):
- """Test initialization from integer value at maximum"""
- obj_type = integer_tuple[0]
- exp_maxvalue = integer_tuple[3]
- obj = obj_type(exp_maxvalue)
- assert obj == exp_maxvalue
-
- @staticmethod
- def test_init_too_low(integer_tuple):
- """Test initialization from integer value below minimum"""
- obj_type = integer_tuple[0]
- exp_minvalue = integer_tuple[2]
- try:
- obj_type(exp_minvalue - 1)
- except ValueError:
- pass
- else:
- raise AssertionError("ValueError was not raised.")
-
- @staticmethod
- def test_init_too_high(integer_tuple):
- """Test initialization from integer value above maximum"""
- obj_type = integer_tuple[0]
- exp_maxvalue = integer_tuple[3]
- try:
- obj_type(exp_maxvalue + 1)
- except ValueError:
- pass
- else:
- raise AssertionError("ValueError was not raised.")
+def test_integer_class_attrs_class(integer_tuple):
+ """Test class attrs via class level"""
+ obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
+ assert obj_type.cimtype == exp_cimtype
+ assert obj_type.minvalue == exp_minvalue
+ assert obj_type.maxvalue == exp_maxvalue
+
+
+def test_integer_class_attrs_inst(integer_tuple):
+ """Test class attrs via instance level"""
+ obj_type, exp_cimtype, exp_minvalue, exp_maxvalue = integer_tuple
+ obj = obj_type(42)
+ assert obj.cimtype == exp_cimtype
+ assert obj.minvalue == exp_minvalue
+ assert obj.maxvalue == exp_maxvalue
+
+
+def test_integer_inheritance(integer_tuple):
+ """Test inheritance"""
+ obj_type = integer_tuple[0]
+ obj = obj_type(42)
+ assert isinstance(obj, obj_type)
+ assert isinstance(obj, CIMType)
+ assert isinstance(obj, CIMInt)
+ assert not isinstance(obj, CIMFloat)
+
+
+def test_integer_init_int(integer_tuple):
+ """Test initialization from integer value"""
+ obj_type = integer_tuple[0]
+ obj = obj_type(42)
+ assert obj == 42
+
+
+def test_integer_init_str(integer_tuple):
+ """Test initialization from string value"""
+ obj_type = integer_tuple[0]
+ obj = obj_type('42')
+ assert obj == 42
+
+
+def test_integer_init_str_base10(integer_tuple):
+ """Test initialization from string value with base 10"""
+ obj_type = integer_tuple[0]
+ obj = obj_type('42', 10)
+ assert obj == 42
+
+
+def test_integer_init_str_base16(integer_tuple):
+ """Test initialization from string value with base 16"""
+ obj_type = integer_tuple[0]
+ obj = obj_type('2A', 16)
+ assert obj == 42
+
+
+def test_integer_init_minimum(integer_tuple):
+ """Test initialization from integer value at minimum"""
+ obj_type = integer_tuple[0]
+ exp_minvalue = integer_tuple[2]
+ obj = obj_type(exp_minvalue)
+ assert obj == exp_minvalue
+
+
+def test_integer_init_maximum(integer_tuple):
+ """Test initialization from integer value at maximum"""
+ obj_type = integer_tuple[0]
+ exp_maxvalue = integer_tuple[3]
+ obj = obj_type(exp_maxvalue)
+ assert obj == exp_maxvalue
+
+
+def test_integer_init_too_low(integer_tuple):
+ """Test initialization from integer value below minimum"""
+ obj_type = integer_tuple[0]
+ exp_minvalue = integer_tuple[2]
+ try:
+ obj_type(exp_minvalue - 1)
+ except ValueError:
+ pass
+ else:
+ raise AssertionError("ValueError was not raised.")
+
+
+def test_integer_init_too_high(integer_tuple):
+ """Test initialization from integer value above maximum"""
+ obj_type = integer_tuple[0]
+ exp_maxvalue = integer_tuple[3]
+ try:
+ obj_type(exp_maxvalue + 1)
+ except ValueError:
+ pass
+ else:
+ raise AssertionError("ValueError was not raised.")
#
@@ -164,47 +158,41 @@ def real_tuple(request):
return request.param
-class TestReals:
- """
- Test CIM real data type classes.
- """
-
- @staticmethod
- def test_class_attrs_class(real_tuple):
- """Test class attrs via class level"""
- obj_type, exp_cimtype = real_tuple
- assert obj_type.cimtype == exp_cimtype
-
- @staticmethod
- def test_class_attrs_inst(real_tuple):
- """Test class attrs via instance level"""
- obj_type, exp_cimtype = real_tuple
- obj = obj_type(42)
- assert obj.cimtype == exp_cimtype
-
- @staticmethod
- def test_inheritance(real_tuple):
- """Test inheritance"""
- obj_type = real_tuple[0]
- obj = obj_type(42)
- assert isinstance(obj, obj_type)
- assert isinstance(obj, CIMType)
- assert isinstance(obj, CIMFloat)
- assert not isinstance(obj, CIMInt)
-
- @staticmethod
- def test_init_float(real_tuple):
- """Test initialization from floating point value"""
- obj_type = real_tuple[0]
- obj = obj_type(42.0)
- assert obj == 42.0
-
- @staticmethod
- def test_init_str(real_tuple):
- """Test initialization from string value"""
- obj_type = real_tuple[0]
- obj = obj_type('42.0')
- assert obj == 42.0
+def test_real_class_attrs_class(real_tuple):
+ """Test class attrs via class level"""
+ obj_type, exp_cimtype = real_tuple
+ assert obj_type.cimtype == exp_cimtype
+
+
+def test_real_class_attrs_inst(real_tuple):
+ """Test class attrs via instance level"""
+ obj_type, exp_cimtype = real_tuple
+ obj = obj_type(42)
+ assert obj.cimtype == exp_cimtype
+
+
+def test_real_inheritance(real_tuple):
+ """Test inheritance"""
+ obj_type = real_tuple[0]
+ obj = obj_type(42)
+ assert isinstance(obj, obj_type)
+ assert isinstance(obj, CIMType)
+ assert isinstance(obj, CIMFloat)
+ assert not isinstance(obj, CIMInt)
+
+
+def test_real_init_float(real_tuple):
+ """Test initialization from floating point value"""
+ obj_type = real_tuple[0]
+ obj = obj_type(42.0)
+ assert obj == 42.0
+
+
+def test_real_init_str(real_tuple):
+ """Test initialization from string value"""
+ obj_type = real_tuple[0]
+ obj = obj_type('42.0')
+ assert obj == 42.0
#
@@ -271,6 +259,26 @@ def test_init_str(real_tuple):
'20140924193040.654321+120'
),
(
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
+ microsecond=654321, tzinfo=MinutesFromUTC(0)),
+ 'timestamp',
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
+ microsecond=654321, tzinfo=MinutesFromUTC(0)),
+ None,
+ 0,
+ '20140924193040.654321+000'
+ ),
+ (
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
+ microsecond=654321),
+ 'timestamp',
+ datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
+ microsecond=654321, tzinfo=MinutesFromUTC(0)),
+ None,
+ 0,
+ '20140924193040.654321+000'
+ ),
+ (
'20140924193040.654321+120',
'timestamp',
datetime(year=2014, month=9, day=24, hour=19, minute=30, second=40,
@@ -325,46 +333,47 @@ def datetime_init_tuple(request):
return request.param
-class TestDatetime:
- """
- Test CIM real data type classes.
- """
-
- @staticmethod
- def test_class_attrs_class():
- """Test class attrs via class level"""
- assert CIMDateTime.cimtype == 'datetime'
-
- @staticmethod
- def test_class_attrs_inst():
- """Test class attrs via instance level"""
- obj = CIMDateTime('00000000000000.000000:000')
- assert obj.cimtype == 'datetime'
-
- @staticmethod
- def test_inheritance():
- """Test inheritance"""
- obj = CIMDateTime('00000000000000.000000:000')
- assert isinstance(obj, CIMDateTime)
- assert isinstance(obj, CIMType)
- assert not isinstance(obj, CIMFloat)
- assert not isinstance(obj, CIMInt)
-
- @staticmethod
- def test_init(datetime_init_tuple):
- """Test initialization from all input types"""
- (dtarg, exp_kind, exp_datetime, exp_timedelta, exp_minutesfromutc,
- exp_str) = datetime_init_tuple
- try:
- obj = CIMDateTime(dtarg)
- except Exception as exc:
- assert isinstance(exc, exp_kind)
- else:
- assert obj.is_interval == (exp_kind == 'interval')
- assert obj.datetime == exp_datetime
- assert obj.timedelta == exp_timedelta
- assert obj.minutes_from_utc == exp_minutesfromutc
- assert str(obj) == exp_str
+def test_datetime_class_attrs_class():
+ """Test class attrs via class level"""
+ assert CIMDateTime.cimtype == 'datetime'
+
+
+def test_datetime_class_attrs_inst():
+ """Test class attrs via instance level"""
+ obj = CIMDateTime('00000000000000.000000:000')
+ assert obj.cimtype == 'datetime'
+
+
+def test_datetime_inheritance():
+ """Test inheritance"""
+ obj = CIMDateTime('00000000000000.000000:000')
+ assert isinstance(obj, CIMDateTime)
+ assert isinstance(obj, CIMType)
+ assert not isinstance(obj, CIMFloat)
+ assert not isinstance(obj, CIMInt)
+
+
+def test_datetime_init(datetime_init_tuple):
+ """Test initialization from all input types"""
+ (dtarg, exp_kind, exp_datetime, exp_timedelta, exp_minutesfromutc,
+ exp_str) = datetime_init_tuple
+ try:
+ obj = CIMDateTime(dtarg)
+ except Exception as exc:
+ assert isinstance(exc, exp_kind)
+ else:
+ assert obj.is_interval == (exp_kind == 'interval')
+ assert obj.datetime == exp_datetime
+ if obj.datetime is not None:
+ assert isinstance(obj.datetime, datetime)
+ # We ensure that the datetime is always timezone-aware:
+ assert obj.datetime.tzinfo is not None
+ assert obj.timedelta == exp_timedelta
+ if obj.timedelta is not None:
+ assert isinstance(obj.timedelta, timedelta)
+ assert obj.minutes_from_utc == exp_minutesfromutc
+ assert str(obj) == exp_str
+
# TODO: Add testcases for get_local_utcoffset()
# TODO: Add testcases for now()

View File

@@ -36,6 +36,8 @@ buildPythonPackage rec {
${python.interpreter} tests/launch_tests.py
'';
LC_ALL="en_US.UTF-8";
meta = {
description = "A Python module to visualise quantum circuit";
homepage = https://github.com/nelimeee/qasm2image;

View File

@@ -3,23 +3,30 @@
, fetchPypi
, setuptools
, pyparsing
, pytest
}:
buildPythonPackage rec {
pname = "svgwrite";
version = "1.1.6";
version = "1.2.1";
src = fetchPypi {
inherit pname version;
sha256 = "1f018813072aa4d7e95e58f133acb3f68fa7de0a0d89ec9402cc38406a0ec5b8";
extension = "zip";
sha256 = "72ef66c9fe367989823cb237ab7f012ac809dd3ba76c1b5ebd9aa61580e2e75e";
};
buildInputs = [ setuptools ];
propagatedBuildInputs = [ pyparsing ];
checkInputs = [ pytest ];
checkPhase = ''
pytest
'';
meta = with stdenv.lib; {
description = "A Python library to create SVG drawings";
homepage = https://bitbucket.org/mozman/svgwrite;
homepage = https://github.com/mozman/svgwrite;
license = licenses.mit;
};

View File

@@ -1,4 +1,4 @@
{ stdenv, buildPythonPackage, fetchPypi, six, mock }:
{ stdenv, buildPythonPackage, fetchPypi, mock, six }:
buildPythonPackage rec {
pname = "whisper";
@@ -10,7 +10,6 @@ buildPythonPackage rec {
};
propagatedBuildInputs = [ six ];
checkInputs = [ mock ];
meta = with stdenv.lib; {