Code Duplication    Length = 24-26 lines in 2 locations

tests/test_smart_dispatch.py 1 location

@@ 115-140 (lines=26) @@
112
        assert_equal(exit_status_100, 2)
113
        assert_true(os.path.isdir(self.logs_dir))
114
115
    @patch('subprocess.check_output')
116
    def test_launch_job_check(self, mock_check_output):
117
118
        #For this test, we won't call the script directly, since we want to mock subprocess.check_output
119
        mock_check_output.side_effect = subprocess.CalledProcessError(1, 1, "A wild error appeared!")
120
        argv = ['-t', '0:0:1', '-G', '1', '-C', '1', '-q', 'random', 'launch', 'echo', 'testing123']
121
122
123
        #Test if the test fail.
124
        try:
125
            with self.assertRaises(SystemExit) as context:
126
                smartdispatch_script.main(argv=argv)
127
128
                self.assertTrue(context.exception.code, 2)
129
130
        except subprocess.CalledProcessError:
131
            self.fail("smartdispatch_script.main() raised CalledProcessError unexpectedly:\n {}".format(traceback.format_exc()))
132
133
        # Test if the test pass (i.e the script run normaly)
134
        mock_check_output.side_effect = None
135
        mock_check_output.return_value = ""
136
137
        try:
138
            smartdispatch_script.main(argv=argv)
139
        except SystemExit as e:
140
            self.fail("The launcher had no problem, but the script failed nonetheless.")
141
142
143
    def test_main_resume(self):

smartdispatch/tests/test_smartdispatch_script.py 1 location

@@ 57-80 (lines=24) @@
54
55
56
57
    @patch('subprocess.check_output')
58
    def test_launch_job_check(self, mock_check_output):
59
60
        mock_check_output.side_effect = subprocess.CalledProcessError(1, 1, "A wild error appeared!")
61
        argv = ['-t', '0:0:1', '-G', '1', '-C', '1', '-q', 'random', 'launch', 'echo', 'testing123']
62
63
        # Test if the test fail.
64
        try:
65
            with self.assertRaises(SystemExit) as context:
66
                smartdispatch_script.main(argv=argv)
67
68
                self.assertTrue(context.exception.code, 2)
69
        
70
        except subprocess.CalledProcessError:
71
            self.fail("smartdispatch_script.main() raised CalledProcessError unexpectedly:\n {}".format(traceback.format_exc()))
72
73
        # Test if the test pass (i.e the script run normaly)
74
        mock_check_output.side_effect = None
75
        mock_check_output.return_value = ""
76
77
        try:
78
            smartdispatch_script.main(argv=argv)
79
        except SystemExit as e:
80
            self.fail("The launcher had no problem, but the script failed nonetheless.")
81