Subject: [bug#49833] bug#49281: Add dynaconf

From: Sarah Morgensen <[email-masked]>
Date: Wed, 04 Aug 2021 11:35:30 -0700

Hello,

While we don't actually require doing this when pypi packages don't have
tests, on a lark I went ahead and switched the source to upstream and
enabled tests to make sure they passed. It looks like two are failing,
but I'm not sure why. I've attached the patch to enable tests and the
test output.

Giacomo Leidi <[email-masked]> writes:

> * gnu/packages/python-xyz.scm (python-dotenv): New variable.
> ---
>  gnu/packages/python-xyz.scm | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
> index cdfc78478c..f415d8b2c8 100644
> --- a/gnu/packages/python-xyz.scm
> +++ b/gnu/packages/python-xyz.scm
> @@ -26239,3 +26239,30 @@ enabling you to write CommonMark inside of Docutils & Sphinx projects.")
>  Qhull} for the computation of the convex hull, Delaunay triangulation, and
>  Voronoi diagram.")
>      (license license:expat)))
> +
> +(define-public python-dotenv
> +  (package
> +    (name "python-dotenv")
> +    (version "0.18.0")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (pypi-uri "python-dotenv" version))
> +       (sha256
> +        (base32
> +         "0b90br3f48ykx5ddfpx2zmsh4vmdqw6s812drcy9pn2q3qyarypg"))))
> +    (build-system python-build-system)
> +    (propagated-inputs
> +     `(("python-click" ,python-click-5)))
> +    (native-inputs
> +     `(("python-mock" ,python-mock)
> +       ("python-pytest" ,python-pytest)
> +       ("python-sh" ,python-sh)))
> +    (home-page
> +     "https://github.com/theskumar/python-dotenv")
       ^ Nitpick: this can go on one line.
> +    (synopsis
> +     "Setup environment variables according to .env files")
       ^ Likewise.
> +    (description
> +     "This package provides the @code{python-dotenv} Python module to
> +read key-value pairs from a .env file and set them as environment variables")
> +    (license license:bsd-3)))

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index f4f3b7fb3f..a5b700f2d3 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -26282,16 +26282,31 @@ Voronoi diagram.")
     (version "0.18.0")
     (source
      (origin
-       (method url-fetch)
-       (uri (pypi-uri "python-dotenv" version))
+       (method git-fetch)
+       (uri
+        (git-reference
+         (url "https://github.com/theskumar/python-dotenv")
+         (commit (string-append "v" version))))
        (sha256
         (base32
-         "0b90br3f48ykx5ddfpx2zmsh4vmdqw6s812drcy9pn2q3qyarypg"))))
+         "1jdccd9s7ypsldafiv0mqgh616662fm5a5ppbhphnin44qv7mir1"))))
     (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (replace 'check
+           (lambda* (#:key tests? inputs outputs #:allow-other-keys)
+             (when tests?
+               (setenv "PATH"
+                       (string-append (assoc-ref outputs "out") "/bin:"
+                                      (getenv "PATH")))
+               (add-installed-pythonpath inputs outputs)
+               (invoke "py.test" "tests/")))))))
     (propagated-inputs
      `(("python-click" ,python-click-5)))
     (native-inputs
-     `(("python-mock" ,python-mock)
+     `(("python-ipython" ,python-ipython)
+       ("python-mock" ,python-mock)
        ("python-pytest" ,python-pytest)
        ("python-sh" ,python-sh)))
     (home-page
starting phase `check'
============================= test session starts ==============================
platform linux -- Python 3.8.2, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /tmp/guix-build-python-dotenv-0.18.0.drv-0/source, inifile: setup.cfg
plugins: hypothesis-5.4.1
collected 132 items

tests/test_cli.py ..F............F..........                             [ 19%]
tests/test_ipython.py ...                                                [ 21%]
tests/test_main.py ..................................................... [ 62%]
                                                                         [ 62%]
tests/test_parser.py ...........................................         [ 94%]
tests/test_utils.py .                                                    [ 95%]
tests/test_variables.py ......                                           [100%]

=================================== FAILURES ===================================
______________________________ test_list_no_file _______________________________

cli = <click.testing.CliRunner object at 0x7ffff5ed8100>

    def test_list_no_file(cli):
        result = cli.invoke(dotenv.cli.list, [])
    
>       assert (result.exit_code, result.output) == (1, "")
E       AssertionError: assert (-1, '') == (1, '')
E         At index 0 diff: -1 != 1
E         Use -v to get the full diff

tests/test_cli.py:31: AssertionError
__________________________ test_set_non_existent_file __________________________

cli = <click.testing.CliRunner object at 0x7ffff5f53cd0>

    def test_set_non_existent_file(cli):
        result = cli.invoke(dotenv.cli.set, ["a", "b"])
    
>       assert (result.exit_code, result.output) == (1, "")
E       AssertionError: assert (-1, '') == (1, '')
E         At index 0 diff: -1 != 1
E         Use -v to get the full diff

tests/test_cli.py:113: AssertionError
=============================== warnings summary ===============================
tests/test_ipython.py::test_ipython_existing_variable_no_override
tests/test_ipython.py::test_ipython_existing_variable_override
tests/test_ipython.py::test_ipython_new_variable
  /gnu/store/m6wza0kv26bnpfaavw8xs1gw2cls6369-python-ipython-7.9.0/lib/python3.8/site-packages/IPython/paths.py:67: UserWarning: IPython parent '/' is not a writable location, using a temp directory.
    warn("IPython parent '{0}' is not a writable location,"

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================== 2 failed, 130 passed, 3 warnings in 4.49s ===================

--
Sarah