Code Duplication    Length = 17-17 lines in 2 locations

unittest-restful.py 1 location

@@ 50-66 (lines=17) @@
47
            ret = requests.get(url, headers={'Accept-encoding': 'identity'})
48
        return ret
49
50
    def test_000_start_server(self):
51
        """Start the Glances Web Server."""
52
        global pid
53
54
        print('INFO: [TEST_000] Start the Glances Web Server API')
55
        if os.path.isfile('./venv/bin/python'):
56
            cmdline = "./venv/bin/python"
57
        else:
58
            cmdline = "python"
59
        cmdline += f" -m glances -B 0.0.0.0 -w -p {SERVER_PORT} --disable-webui -C ./conf/glances.conf"
60
        print(f"Run the Glances Web Server on port {SERVER_PORT}")
61
        args = shlex.split(cmdline)
62
        pid = subprocess.Popen(args)
63
        print("Please wait 5 seconds...")
64
        time.sleep(5)
65
66
        self.assertTrue(pid is not None)
67
68
    def test_001_all(self):
69
        """All."""

unittest-xmlrpc.py 1 location

@@ 41-57 (lines=17) @@
38
        """The function is called *every time* before test_*."""
39
        print('\n' + '=' * 78)
40
41
    def test_000_start_server(self):
42
        """Start the Glances Web Server."""
43
        global pid
44
45
        print('INFO: [TEST_000] Start the Glances Web Server')
46
        if os.path.isfile('./venv/bin/python'):
47
            cmdline = "./venv/bin/python"
48
        else:
49
            cmdline = "python"
50
        cmdline += f" -m glances -B localhost -s -p {SERVER_PORT}"
51
        print(f"Run the Glances Server on port {SERVER_PORT}")
52
        args = shlex.split(cmdline)
53
        pid = subprocess.Popen(args)
54
        print("Please wait...")
55
        time.sleep(1)
56
57
        self.assertTrue(pid is not None)
58
59
    def test_001_all(self):
60
        """All."""