Code Duplication    Length = 30-31 lines in 2 locations

tests/test_smart_dispatch.py 1 location

@@ 116-146 (lines=31) @@
113
        assert_equal(exit_status_100, 2)
114
        assert_true(os.path.isdir(self.logs_dir))
115
116
117
    def test_gpu_check(self):
118
119
        argv = ['-x', '-g', '2', '-G', '1', '-C', '1', '-q', 'random', '-t', '00:00:10' ,'launch', 'echo', 'testing123']
120
121
        # Test if the check fail
122
        with self.assertRaises(SystemExit) as context:
123
            smartdispatch_script.main(argv=argv)
124
125
        self.assertTrue(context.exception.code, 2)
126
127
        # Test if the test pass
128
        argv[2] = '0'
129
130
        try:
131
            smartdispatch_script.main(argv=argv)
132
        except SystemExit as e:
133
            self.fail("The command failed the check, but it was supposed to pass.")
134
135
136
    def test_cpu_check(self):
137
138
        argv = ['-x', '-c', '2', '-C', '1', '-G', '1', '-t', '00:00:10', '-q', 'random', 'launch', 'echo', 'testing123']
139
140
        # Test if the check fail
141
        with self.assertRaises(SystemExit) as context:
142
            smartdispatch_script.main(argv=argv)
143
144
        self.assertTrue(context.exception.code, 2)
145
146
        # Test if the test pass
147
        argv[2] = '1'
148
149
        try:

smartdispatch/tests/test_smartdispatch_script.py 1 location

@@ 58-87 (lines=30) @@
55
56
57
58
    @patch('subprocess.check_output')
59
    def test_launch_job_check(self, mock_check_output):
60
61
        argv = ['-t', '0:0:1', '-G', '1', '-C', '1', '-q', 'random', 'launch', 'echo', 'testing123']
62
63
        # Test if the test pass (i.e the script run normaly)
64
        mock_check_output.side_effect = None
65
        mock_check_output.return_value = ""
66
67
        try:
68
            smartdispatch_script.main(argv=argv)
69
        except SystemExit as e:
70
          self.fail("The launcher had no problem, but the script failed nonetheless.")
71
72
        mock_check_output.side_effect = subprocess.CalledProcessError(1, "echo blabla", "A wild error appeared!")
73
74
        # Test if the test fail.
75
        try:
76
            with self.assertRaises(SystemExit) as context:
77
                smartdispatch_script.main(argv=argv)
78
79
                self.assertTrue(context.exception.code, 2)
80
        
81
        except subprocess.CalledProcessError as e:
82
            # Rerasing the exception
83
            orig_exc_type, orig_exc_value, orig_exc_traceback = sys.exc_info()
84
            
85
            new_exc = Exception("smartdispatch_script.main() raised subprocess.CalledProcessError unexpectedly")
86
            new_exc.reraised = True
87
            six.reraise(type(new_exc), new_exc, orig_exc_traceback)
88