[med-svn] [Git][python-team/packages/python-stubserver][master] 3 commits: Ensure tests do not generate leftover data
Athos Ribeiro (@athos)
gitlab at salsa.debian.org
Sun Dec 4 16:47:15 GMT 2022
Athos Ribeiro pushed to branch master at Debian Python Team / packages / python-stubserver
Commits:
31ec089c by Athos Ribeiro at 2022-12-04T13:42:15-03:00
Ensure tests do not generate leftover data
- - - - -
80bc7e41 by Athos Ribeiro at 2022-12-04T13:43:40-03:00
Run tests with pytest instead of setup.py test
- - - - -
09aa514d by Athos Ribeiro at 2022-12-04T13:43:59-03:00
Update changelog
- - - - -
6 changed files:
- debian/changelog
- debian/control
- + debian/patches/0001-Ensure-tests-do-not-generate-leftover-data.patch
- debian/patches/series
- + debian/pybuild.testfiles
- debian/rules
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+python-stubserver (1.1-4) UNRELEASED; urgency=medium
+
+ * Team upload.
+ * d/p/0001-Ensure-tests-do-not-generate-leftover-data.patch: generate test
+ data files in temporary paths and clean up after test runs.
+ * Run tests with pytest instead of setup.py test.
+
+ -- Athos Ribeiro <athoscribeiro at gmail.com> Sun, 04 Dec 2022 11:26:23 -0300
+
python-stubserver (1.1-3) unstable; urgency=medium
* Team upload.
=====================================
debian/control
=====================================
@@ -6,6 +6,7 @@ Uploaders: Michael R. Crusoe <crusoe at debian.org>
Build-Depends: debhelper-compat (= 13),
python3-all,
dh-python,
+ python3-pytest <!nocheck>,
python3-setuptools,
python3-requests <!nocheck>
Standards-Version: 4.6.0
=====================================
debian/patches/0001-Ensure-tests-do-not-generate-leftover-data.patch
=====================================
@@ -0,0 +1,50 @@
+From ff03f8633c445b5bcd83ab3cd0d47069ca159f80 Mon Sep 17 00:00:00 2001
+From: Athos Ribeiro <athoscribeiro at gmail.com>
+Date: Sun, 4 Dec 2022 13:15:41 -0300
+Subject: [PATCH] Ensure tests do not generate leftover data
+
+Forwarded: https://github.com/tarttelin/Python-Stub-Server/pull/20
+Last-Update: 2022-12-04
+---
+ test.py | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/test.py b/test.py
+index 397357e..eab37d3 100644
+--- a/test.py
++++ b/test.py
+@@ -1,6 +1,8 @@
++import os
+ import unittest
+ import requests
+ import sys
++import tempfile
+ from io import BytesIO
+ from ftplib import FTP
+ from stubserver import StubServer, FTPStubServer
+@@ -33,16 +35,19 @@ class WebTest(TestCase):
+ return (response, response_code)
+
+ def test_get_with_file_call(self):
+- with open('data.txt', 'w') as f:
++ data_file = None
++ with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
+ f.write("test file")
+- self.server.expect(method="GET", url="/address/\d+$").and_return(mime_type="text/xml", file_content="./data.txt")
++ data_file = f.name
++ self.server.expect(method="GET", url="/address/\d+$").and_return(mime_type="text/xml", file_content=data_file)
+ response, response_code = self._make_request("http://localhost:8998/address/25", method="GET")
+- with open("./data.txt", "r") as f:
++ with open(data_file, "r") as f:
+ expected = f.read().encode('utf-8')
+ try:
+ self.assertEqual(expected, response.read())
+ finally:
+ response.close()
++ os.unlink(data_file)
+
+ def test_put_with_capture(self):
+ capture = {}
+--
+2.37.2
+
=====================================
debian/patches/series
=====================================
@@ -1 +1,2 @@
test
+0001-Ensure-tests-do-not-generate-leftover-data.patch
=====================================
debian/pybuild.testfiles
=====================================
@@ -0,0 +1 @@
+test.py
=====================================
debian/rules
=====================================
@@ -4,6 +4,7 @@
export LC_ALL=C.UTF-8
export PYBUILD_NAME=stubserver
+export PYBUILD_TEST_ARGS=test.py
%:
dh $@ --with python3 --buildsystem=pybuild
View it on GitLab: https://salsa.debian.org/python-team/packages/python-stubserver/-/compare/759eb7f3101b2311a7da1611f1ff15b6ec8268f8...09aa514d14ede64cccb92e4761e0d3d6cc3b5bb1
--
View it on GitLab: https://salsa.debian.org/python-team/packages/python-stubserver/-/compare/759eb7f3101b2311a7da1611f1ff15b6ec8268f8...09aa514d14ede64cccb92e4761e0d3d6cc3b5bb1
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20221204/02d6fe26/attachment-0001.htm>
More information about the debian-med-commit
mailing list