summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/applications/networking/dyndns/dyndnsc/default.nix7
-rw-r--r--pkgs/development/python-modules/json-logging/default.nix49
-rw-r--r--pkgs/development/python-modules/pytest-console-scripts/default.nix41
-rw-r--r--pkgs/top-level/python-packages.nix4
4 files changed, 98 insertions, 3 deletions
diff --git a/pkgs/applications/networking/dyndns/dyndnsc/default.nix b/pkgs/applications/networking/dyndns/dyndnsc/default.nix
index 65d46305741..66b1d2639d6 100644
--- a/pkgs/applications/networking/dyndns/dyndnsc/default.nix
+++ b/pkgs/applications/networking/dyndns/dyndnsc/default.nix
@@ -2,11 +2,11 @@
 
 python3Packages.buildPythonApplication rec {
   pname = "dyndnsc";
-  version = "0.5.1";
+  version = "0.6.1";
 
   src = python3Packages.fetchPypi {
     inherit pname version;
-    hash = "sha256-Sy6U0XhIQ9mPmznmWKqoyqE34vaE84fwlivouaF7Dd0=";
+    sha256 = "13078d29eea2f9a4ca01f05676c3309ead5e341dab047e0d51c46f23d4b7fbb4";
   };
 
   postPatch = ''
@@ -19,9 +19,10 @@ python3Packages.buildPythonApplication rec {
     dnspython
     netifaces
     requests
+    json-logging
     setuptools
   ];
-  checkInputs = with python3Packages; [ bottle pytestCheckHook ];
+  checkInputs = with python3Packages; [ bottle mock pytest-console-scripts pytestCheckHook ];
 
   disabledTests = [
     # dnswanip connects to an external server to discover the
diff --git a/pkgs/development/python-modules/json-logging/default.nix b/pkgs/development/python-modules/json-logging/default.nix
new file mode 100644
index 00000000000..3d34cb2475a
--- /dev/null
+++ b/pkgs/development/python-modules/json-logging/default.nix
@@ -0,0 +1,49 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, fetchpatch
+, pytestCheckHook
+, wheel
+, flask
+, sanic
+, fastapi
+, uvicorn
+, requests
+}:
+
+buildPythonPackage rec {
+  pname = "json-logging";
+  version = "1.3.0";
+
+  src = fetchFromGitHub {
+    owner = "bobbui";
+    repo = "json-logging-python";
+    rev = version;
+    hash = "sha256-0eIhOi30r3ApyVkiBdTQps5tNj7rI+q8TjNWxTnhtMQ=";
+  };
+  patches = [
+    # Fix tests picking up test modules instead of real packages.
+    (fetchpatch {
+      url = "https://github.com/bobbui/json-logging-python/commit/6fdb64deb42fe48b0b12bda0442fd5ac5f03107f.patch";
+      sha256 = "sha256-BLfARsw2FdvY22NCaFfdFgL9wTmEZyVIi3CQpB5qU0Y=";
+    })
+  ];
+
+  # - Quart is not packaged for Nixpkgs.
+  # - FastAPI is broken, see #112701 and tiangolo/fastapi#2335.
+  checkInputs = [ wheel flask /*quart*/ sanic /*fastapi*/ uvicorn requests pytestCheckHook ];
+  disabledTests = [ "quart" "fastapi" ];
+  disabledTestPaths = [ "tests/test_fastapi.py" ];
+  # Tests spawn servers and try to connect to them.
+  __darwinAllowLocalNetworking = true;
+
+  meta = with lib; {
+    description = "Python library to emit logs in JSON format";
+    longDescription = ''
+      Python logging library to emit JSON log that can be easily indexed and searchable by logging infrastructure such as ELK, EFK, AWS Cloudwatch, GCP Stackdriver.
+    '';
+    homepage = "https://github.com/bobbui/json-logging-python";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ AluisioASG ];
+  };
+}
diff --git a/pkgs/development/python-modules/pytest-console-scripts/default.nix b/pkgs/development/python-modules/pytest-console-scripts/default.nix
new file mode 100644
index 00000000000..aaecd191e93
--- /dev/null
+++ b/pkgs/development/python-modules/pytest-console-scripts/default.nix
@@ -0,0 +1,41 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, pytestCheckHook
+, python
+, mock
+, setuptools-scm
+}:
+
+buildPythonPackage rec {
+  pname = "pytest-console-scripts";
+  version = "1.2.0";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "4a2138d7d567bc581fe081b6a5975849a2a36b3925cb0f066d2380103e13741c";
+  };
+  postPatch = ''
+    # setuptools-scm is pinned to <6 because it dropped Python 3.5
+    # support.  That's not something that affects us.
+    substituteInPlace setup.py --replace "'setuptools_scm<6'" "'setuptools_scm'"
+    # Patch the shebang of a script generated during test.
+    substituteInPlace tests/test_run_scripts.py --replace "#!/usr/bin/env python" "#!${python.interpreter}"
+  '';
+
+  SETUPTOOLS_SCM_PRETEND_VERSION = version;
+  nativeBuildInputs = [ setuptools-scm ];
+
+  checkInputs = [ mock pytestCheckHook ];
+
+  meta = with lib; {
+    description = "Pytest plugin for testing console scripts";
+    longDescription = ''
+      Pytest-console-scripts is a pytest plugin for running python scripts from within tests.
+      It's quite similar to subprocess.run(), but it also has an in-process mode, where the scripts are executed by the interpreter that's running pytest (using some amount of sandboxing).
+    '';
+    homepage = "https://github.com/kvas-it/pytest-console-scripts";
+    license = licenses.mit;
+    maintainers = with maintainers; [ AluisioASG ];
+  };
+}
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 90f766ed459..ec7afc633ea 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -3443,6 +3443,8 @@ in {
 
   jsonlines = callPackage ../development/python-modules/jsonlines { };
 
+  json-logging = callPackage ../development/python-modules/json-logging { };
+
   jsonmerge = callPackage ../development/python-modules/jsonmerge { };
 
   json-merge-patch = callPackage ../development/python-modules/json-merge-patch { };
@@ -6259,6 +6261,8 @@ in {
 
   pytest-click = callPackage ../development/python-modules/pytest-click { };
 
+  pytest-console-scripts = callPackage ../development/python-modules/pytest-console-scripts { };
+
   pytest-cov = self.pytestcov; # self 2021-01-04
   pytestcov = callPackage ../development/python-modules/pytest-cov { };