File: test_examples.py

package info (click to toggle)
python-pulp 2.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,720 kB
  • sloc: python: 7,505; makefile: 16; sh: 16
file content (36 lines) | stat: -rw-r--r-- 915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import unittest
import pulp
import shutil


class Examples_DocsTests(unittest.TestCase):
    def test_examples(self, examples_dir="../../examples"):
        import importlib

        this_file = os.path.realpath(__file__)
        parent_dir = os.path.dirname(this_file)
        files = os.listdir(os.path.join(parent_dir, examples_dir))
        TMP_dir = "_tmp/"
        if not os.path.exists(TMP_dir):
            os.mkdir(TMP_dir)
        for f_name in files:
            if os.path.isdir(f_name):
                continue
            _f_name = "examples." + os.path.splitext(f_name)[0]
            os.chdir(TMP_dir)
            importlib.import_module(_f_name)
            os.chdir("../")
        shutil.rmtree(TMP_dir)

    def test_doctest(self):
        """
        runs all doctests
        """
        import doctest

        doctest.testmod(pulp)


if __name__ == "__main__":
    unittest.main()