src/pyams_zmq/tests/test_utilsdocstrings.py
changeset 25 9352acb9366b
parent 0 11f0f97d508f
--- a/src/pyams_zmq/tests/test_utilsdocstrings.py	Fri Jan 11 13:52:29 2019 +0100
+++ b/src/pyams_zmq/tests/test_utilsdocstrings.py	Thu Nov 28 19:19:25 2019 +0100
@@ -1,5 +1,7 @@
+# -*- coding: utf-8 -*- ######################################################
+##############################################################################
 #
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# Copyright (c) 2008-2010 Thierry Florac <tflorac AT ulthar.net>
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -9,19 +11,23 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+##############################################################################
 
 """
-Generic Test case for pyams_zmq doc strings
+Generic test case for pyams_zmq doc strings
 """
+
 __docformat__ = 'restructuredtext'
 
+import doctest
+import os
 import unittest
-import doctest
-import sys
-import os
+
+from pyams_utils.tests import get_package_dir
 
 
-current_dir = os.path.abspath(os.path.dirname(__file__))
+CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
+
 
 def doc_suite(test_dir, globs=None):
     """Returns a test suite, based on doc tests strings found in /*.py"""
@@ -32,9 +38,7 @@
     flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
              doctest.REPORT_ONLY_FIRST_FAILURE)
 
-    package_dir = os.path.split(test_dir)[0]
-    if package_dir not in sys.path:
-        sys.path.append(package_dir)
+    package_dir = get_package_dir(test_dir)
 
     # filtering files on extension
     docs = [doc for doc in
@@ -42,7 +46,7 @@
     docs = [doc for doc in docs if not doc.startswith('__')]
 
     for test in docs:
-        fd = open(os.path.join(package_dir, test))
+        fd = open(os.path.join(package_dir, test))  # pylint: disable=invalid-name
         content = fd.read()
         fd.close()
         if '>>> ' not in content:
@@ -54,9 +58,11 @@
 
     return unittest.TestSuite(suite)
 
+
 def test_suite():
     """returns the test suite"""
-    return doc_suite(current_dir)
+    return doc_suite(CURRENT_DIR)
+
 
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')