commit:     20230490139219be66382115c9f1d0b614d8dad7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 24 09:07:23 2023 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Jun 24 11:32:13 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=20230490

dev-python/pymongo: Support running the test suite without mongodb

Add IUSE=test-full and support running the test suite without a running
mongodb server when it is disabled.  This makes it possible to keyword
pymongo on architectures where the low quality mongodb software does
not build.

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/pymongo/metadata.xml         |  6 ++++++
 dev-python/pymongo/pymongo-4.4.0.ebuild | 21 +++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/dev-python/pymongo/metadata.xml b/dev-python/pymongo/metadata.xml
index 9fefebbe96bd..49d5ee837cb8 100644
--- a/dev-python/pymongo/metadata.xml
+++ b/dev-python/pymongo/metadata.xml
@@ -12,6 +12,12 @@
        <longdescription lang="en">PyMongo is a Python distribution containing 
tools 
        for working with MongoDB, and is the recommended way to work 
        with MongoDB from Python.</longdescription>
+       <use>
+               <flag name="test-full">
+                       Run test suite in full, including tests that run a local
+                       database instance.
+               </flag>
+       </use>
        <upstream>
                <remote-id type="pypi">pymongo</remote-id>
                <remote-id type="github">mongodb/mongo-python-driver</remote-id>

diff --git a/dev-python/pymongo/pymongo-4.4.0.ebuild 
b/dev-python/pymongo/pymongo-4.4.0.ebuild
index e39037ff6b3b..39b138a7bd5f 100644
--- a/dev-python/pymongo/pymongo-4.4.0.ebuild
+++ b/dev-python/pymongo/pymongo-4.4.0.ebuild
@@ -24,14 +24,14 @@ S=${WORKDIR}/${MY_P}
 LICENSE="Apache-2.0"
 SLOT="0"
 KEYWORDS="~amd64 ~arm64 ~hppa ~riscv ~x86"
-IUSE="doc kerberos"
+IUSE="doc kerberos +test-full"
 
 RDEPEND="
        <dev-python/dnspython-3.0.0[${PYTHON_USEDEP}]
        kerberos? ( dev-python/pykerberos[${PYTHON_USEDEP}] )
 "
 BDEPEND="
-       test? (
+       test-full? (
                >=dev-db/mongodb-2.6.0
        )
 "
@@ -40,7 +40,7 @@ distutils_enable_sphinx doc
 distutils_enable_tests unittest
 
 reqcheck() {
-       if use test; then
+       if use test-full; then
                # During the tests, database size reaches 1.5G.
                local CHECKREQS_DISK_BUILD=1536M
 
@@ -72,11 +72,16 @@ src_prepare() {
 }
 
 python_test() {
-       # Yes, we need TCP/IP for that...
-       local DB_IP=127.0.0.1
-       local DB_PORT=27000
+       if ! use test-full; then
+               # .invalid is guaranteed to return NXDOMAIN per RFC 6761
+               local -x DB_IP=mongodb.invalid
+               esetup.py test
+               return
+       fi
 
-       export DB_IP DB_PORT
+       # Yes, we need TCP/IP for that...
+       local -x DB_IP=127.0.0.1
+       local -x DB_PORT=27000
 
        local dbpath=${TMPDIR}/mongo.db
        local logpath=${TMPDIR}/mongod.log
@@ -116,7 +121,7 @@ python_test() {
        done
 
        local failed
-       esetup.py test || failed=1
+       nonfatal esetup.py test || failed=1
 
        mongod --dbpath "${dbpath}" --shutdown || die
 

Reply via email to