pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

py-cvss: Add support for running the unit tests



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Thu Jun 21 10:09:45 2018 +0200
Changeset:	b52b63e69c3d427dcc9d8a3145fb07610df24cd6

Modified Files:
	py-cvss/Makefile
	py-cvss/distinfo
Added Files:
	py-cvss/patches/patch-tests_test__cvss2.py
	py-cvss/patches/patch-tests_test__cvss3.py

Log Message:
py-cvss: Add support for running the unit tests

- Define a `do-test' target that directly call the Python scripts
  to test the cvss module.
- Add patches/patch-tests_test__cvss[23].py to always import the
  `cvss' module from the parent directory of the test. Idea shamelessy
  stolen from youtube-dl.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=b52b63e69c3d427dcc9d8a3145fb07610df24cd6

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 py-cvss/Makefile                           |  4 ++++
 py-cvss/distinfo                           |  2 ++
 py-cvss/patches/patch-tests_test__cvss2.py | 16 ++++++++++++++++
 py-cvss/patches/patch-tests_test__cvss3.py | 16 ++++++++++++++++
 4 files changed, 38 insertions(+)

diffs:
diff --git a/py-cvss/Makefile b/py-cvss/Makefile
index ab5d3671e5..99ebf33e55 100644
--- a/py-cvss/Makefile
+++ b/py-cvss/Makefile
@@ -14,6 +14,10 @@ LICENSE=	gnu-lgpl-v3
 
 USE_LANGUAGES=	# none
 
+do-test:
+	${RUN} cd ${WRKSRC}/tests; ${SETENV} ${TEST_ENV} ${PYTHONBIN} test_cvss2.py
+	${RUN} cd ${WRKSRC}/tests; ${SETENV} ${TEST_ENV} ${PYTHONBIN} test_cvss3.py
+
 post-install:
 	${MV} ${DESTDIR}${PREFIX}/bin/cvss_calculator ${DESTDIR}${PREFIX}/bin/cvss_calculator-${PYVERSSUFFIX} || ${TRUE}
 
diff --git a/py-cvss/distinfo b/py-cvss/distinfo
index 75b8056375..358ce9d834 100644
--- a/py-cvss/distinfo
+++ b/py-cvss/distinfo
@@ -4,3 +4,5 @@ SHA1 (cvss-1.7.tar.gz) = 76ebd64e66783ce615db34ac46a67674bca0934e
 RMD160 (cvss-1.7.tar.gz) = 3e32f253d4cbe91696fc13cda29a77878eaa52f6
 SHA512 (cvss-1.7.tar.gz) = e2437afd1cd3aceb5884fc1d3203d9be0308591dbecbecaa3c8284f22efc6703797cc75ecaf79e136f3b987562552cccd6b4092b3354d05e9de0bbd97dfc57e0
 Size (cvss-1.7.tar.gz) = 3178715 bytes
+SHA1 (patch-tests_test__cvss2.py) = 9f1c51bf48d944b30bbe58cd3e3e232325e28f99
+SHA1 (patch-tests_test__cvss3.py) = 83de56438bf4a95b1737cc48fd4bba6ab553d54e
diff --git a/py-cvss/patches/patch-tests_test__cvss2.py b/py-cvss/patches/patch-tests_test__cvss2.py
new file mode 100644
index 0000000000..c08cc06999
--- /dev/null
+++ b/py-cvss/patches/patch-tests_test__cvss2.py
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Pick up `cvss' module from the parent directory in order to properly
+run the tests without having the cvss module installed.
+
+--- tests/test_cvss2.py.orig	2017-01-11 09:11:40.000000000 +0000
++++ tests/test_cvss2.py
+@@ -2,6 +2,8 @@ from os import path
+ import sys
+ import unittest
+ 
++sys.path.insert(0, path.dirname(path.dirname(path.abspath(__file__))))
++
+ from cvss import CVSS2
+ from cvss.exceptions import CVSS2MalformedError, CVSS2MandatoryError, CVSS2RHScoreDoesNotMatch, \
+     CVSS2RHMalformedError
diff --git a/py-cvss/patches/patch-tests_test__cvss3.py b/py-cvss/patches/patch-tests_test__cvss3.py
new file mode 100644
index 0000000000..2b06b43811
--- /dev/null
+++ b/py-cvss/patches/patch-tests_test__cvss3.py
@@ -0,0 +1,16 @@
+$NetBSD$
+
+Pick up `cvss' module from the parent directory in order to properly
+run the tests without having the cvss module installed.
+
+--- tests/test_cvss3.py.orig	2017-01-11 09:11:40.000000000 +0000
++++ tests/test_cvss3.py
+@@ -2,6 +2,8 @@ from os import path
+ import sys
+ import unittest
+ 
++sys.path.insert(0, path.dirname(path.dirname(path.abspath(__file__))))
++
+ from cvss import CVSS3
+ from cvss.exceptions import CVSS3MalformedError, CVSS3MandatoryError, CVSS3RHScoreDoesNotMatch, \
+     CVSS3RHMalformedError


Home | Main Index | Thread Index | Old Index