[arch-commits] Commit in python-dpcontracts/trunk (2 files)

Eli Schwartz eschwartz at archlinux.org
Sun Jul 5 15:19:57 UTC 2020


    Date: Sunday, July 5, 2020 @ 15:19:56
  Author: eschwartz
Revision: 657859

upgpkg: python-dpcontracts 0.6.0-5: fix FTBFS due to patch never applying

It would infinitely hang during prepare() waiting for input, then fail to patch
the tests, so the tests never ran.

Fix by properly backporting the doctests so the patch applies without errors.

Added:
  python-dpcontracts/trunk/0001-fixing-tox-test-of-README.patch
Modified:
  python-dpcontracts/trunk/PKGBUILD

--------------------------------------+
 0001-fixing-tox-test-of-README.patch |  141 +++++++++++++++++++++++++++++++++
 PKGBUILD                             |    8 -
 2 files changed, 145 insertions(+), 4 deletions(-)

Added: 0001-fixing-tox-test-of-README.patch
===================================================================
--- 0001-fixing-tox-test-of-README.patch	                        (rev 0)
+++ 0001-fixing-tox-test-of-README.patch	2020-07-05 15:19:56 UTC (rev 657859)
@@ -0,0 +1,141 @@
+From bedd5b5f86abe12fe2754a78271b4547d1315c5d Mon Sep 17 00:00:00 2001
+From: AlexV <asmodehn at gmail.com>
+Date: Sun, 16 Sep 2018 15:27:41 +0100
+Subject: [PATCH] fixing tox test of README.
+
+(cherry picked from commit a70f208959542cfb5e599d41cdc16da510179a55)
+[drop unrelated, non-mergeable changes for stable release -- Eli Schwartz]
+---
+ README.rst | 31 ++++++++++++++++++++-----------
+ 1 file changed, 20 insertions(+), 11 deletions(-)
+
+diff --git a/README.rst b/README.rst
+index 49173a8..39663aa 100644
+--- a/README.rst
++++ b/README.rst
+@@ -41,6 +41,9 @@ functionality except support for "async def" functions.
+ 
+ Preconditions and Postconditions
+ ================================
++
++    >>> from dpcontracts import require, ensure
++
+ Contracts on functions consist of preconditions and postconditions.
+ A precondition is declared using the `requires` decorator, and describes
+ what must be true upon entrance to the function. The condition function
+@@ -67,7 +70,7 @@ with a PreconditionError (a subtype of AssertionError):
+ 
+     >>> add2("foo", 2)
+     Traceback (most recent call last):
+-    PreconditionError: `i` must be an integer
++    dpcontracts.PreconditionError: `i` must be an integer
+ 
+ Functions can also have postconditions, specified using the `ensure`
+ decorator.  Postconditions describe what must be true after the function
+@@ -95,7 +98,7 @@ Except that the function is broken in unexpected ways:
+ 
+     >>> add2(7, 4)
+     Traceback (most recent call last):
+-    PostconditionError: the result must be greater than either `i` or `j`
++    dpcontracts.PostconditionError: the result must be greater than either `i` or `j`
+ 
+ The function specifying the condition doesn't have to be a lambda; it can be
+ any function, and pre- and postconditions don't have to actually reference
+@@ -118,10 +121,10 @@ the function's environments and effects:
+     >>> add_to_database("Marvin")
+     >>> add_to_database("Marvin")
+     Traceback (most recent call last):
+-    PreconditionError: `name` must not already be in the database
++    dpcontracts.PreconditionError: `name` must not already be in the database
+     >>> add_to_database("Rob")
+     Traceback (most recent call last):
+-    PostconditionError: the normalized version of the name must be added to the database
++    dpcontracts.PostconditionError: the normalized version of the name must be added to the database
+ 
+ All of the various calling conventions of Python are supported:
+ 
+@@ -146,6 +149,8 @@ A common contract is to validate the types of arguments. To that end,
+ there is an additional decorator, `types`, that can be used
+ to validate arguments' types:
+ 
++    >>> from dpcontracts import types
++
+     >>> class ExampleClass:
+     ...     pass
+ 
+@@ -159,11 +164,11 @@ to validate arguments' types:
+ 
+     >>> func(1.0, "foo", ExampleClass) # invalid type for `a`
+     Traceback (most recent call last):
+-    PreconditionError: the types of arguments must be valid
++    dpcontracts.PreconditionError: the types of arguments must be valid
+ 
+     >>> func(1, "foo") # invalid type (the default) for `c`
+     Traceback (most recent call last):
+-    PreconditionError: the types of arguments must be valid
++    dpcontracts.PreconditionError: the types of arguments must be valid
+ 
+ Contracts on Classes
+ ====================
+@@ -181,7 +186,7 @@ not just bare functions:
+ 
+     >>> foo = Foo("")
+     Traceback (most recent call last):
+-    PreconditionError: `name` should be nonempty
++    dpcontracts.PreconditionError: `name` should be nonempty
+ 
+ Classes may also have an additional sort of contract specified over them:
+ the invariant.  An invariant, created using the `invariant` decorator,
+@@ -190,6 +195,8 @@ In this case, "always" means "before invocation of any method and after
+ its return" -- methods are allowed to violate invariants so long as they
+ are restored prior to return.
+ 
++    >>> from dpcontracts import invariant
++
+ Invariant contracts are passed a single variable, a reference to the
+ instance of the class. For example:
+ 
+@@ -222,11 +229,11 @@ instance of the class. For example:
+     >>> nl.pop()
+     >>> nl.pop()
+     Traceback (most recent call last):
+-    PostconditionError: inner list can never be empty
++    dpcontracts.PostconditionError: inner list can never be empty
+ 
+     >>> nl = NonemptyList(["a", "b", "c"])
+     Traceback (most recent call last):
+-    PostconditionError: inner list must consist only of integers
++    dpcontracts.PostconditionError: inner list must consist only of integers
+ 
+ Violations of invariants are ignored in the following situations:
+ 
+@@ -265,7 +272,7 @@ For example:
+     >>> x.break_everything()
+     >>> x.get_always()
+     Traceback (most recent call last):
+-    PreconditionError: `always` should be True
++    dpcontracts.PreconditionError: `always` should be True
+ 
+ Also note that if a method invokes another method on the same object,
+ all of the invariants will be tested again:
+@@ -295,7 +302,7 @@ This works well in most situations:
+     6
+     >>> my_func([0, -1, 2])
+     Traceback (most recent call last):
+-    PreconditionError: every item in `l` must be > 0
++    dpcontracts.PreconditionError: every item in `l` must be > 0
+ 
+ But it fails in the case of a generator:
+ 
+@@ -319,6 +326,8 @@ We get around that limitation here using an additional decorator, called
+ `transform` that transforms the arguments to a function, and a function
+ called `rewrite` that rewrites argument tuples.
+ 
++    >>> from dpcontracts import transform, rewrite
++
+ For example:
+ 
+     >>> @transform(lambda args: rewrite(args, l=list(args.l)))
+-- 
+2.27.0
+

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2020-07-05 15:19:09 UTC (rev 657858)
+++ PKGBUILD	2020-07-05 15:19:56 UTC (rev 657859)
@@ -2,7 +2,7 @@
 
 pkgname=python-dpcontracts
 pkgver=0.6.0
-pkgrel=4
+pkgrel=5
 pkgdesc="A simple implementation of contracts for Python"
 url="https://github.com/deadpixi/contracts"
 license=('LGPL')
@@ -11,13 +11,13 @@
 makedepends=('python-setuptools')
 checkdepends=('python-pytest-runner')
 source=("https://pypi.io/packages/source/d/dpcontracts/dpcontracts-$pkgver.tar.gz"
-        https://github.com/deadpixi/contracts/commit/a70f208959542cfb5e599d41cdc16da510179a55.patch)
+        "0001-fixing-tox-test-of-README.patch")
 sha512sums=('451b541c87ee2ccad3ab18f2328ffffff0fd422e137af8227b7c264f7b91b4270de077f79596008f746a37aef1e5762278b209b8923a6126a74a3b32225d4dd5'
-            'd3022db1dd519b1b0fa45994259e50696cde726926412551b0eed7d833466d7c7d9e23da09c53af3f2e18efa9950bd3e1ecc9e39a02421fe47453bfa5139f830')
+            'abbe0c19e9f4207a60a36cbcddf3202e1f4477768b836c8cbed9b687d6fe99650db333353ddf3f3535828964a01a9e2c3838d8325c254a835f4ad7a195b666b7')
 
 prepare() {
   cd dpcontracts-$pkgver
-  patch -p1 -i ../a70f208959542cfb5e599d41cdc16da510179a55.patch || :
+  patch -p1 -i ../0001-fixing-tox-test-of-README.patch
 }
 
 build() {



More information about the arch-commits mailing list