← Back to team overview

sikuli-driver team mailing list archive

[Question #250441]: [1.1.0 beta1] get error while invoke unittest.main()

 

New question #250441 on Sikuli:
https://answers.launchpad.net/sikuli/+question/250441


Run the sample code form unittest document in SikuliX IDE, get a SystemExit error:
[error] script [ test ] stopped with error in line 64
[error] SystemExit ( False )

But there is no such issue if run this unit test using TextTestRunner. Below is the sample code.

import os
import sys
import subprocess

import random
import unittest

class TestSequenceFunctions(unittest.TestCase):

    def setUp(self):
        self.seq = range(10)
        #self.proc = subprocess.Popen("explorer", shell=True)
        #wait(2)

    def test_shuffle(self):
        # make sure the shuffled sequence does not lose any elements
        random.shuffle(self.seq)
        self.seq.sort()
        self.assertEqual(self.seq, range(10))

        # should raise an exception for an immutable sequence
        self.assertRaises(TypeError, random.shuffle, (1,2,3))

    def test_choice(self):
        element = random.choice(self.seq)
        self.assertTrue(element in self.seq)

    def test_sample(self):
        with self.assertRaises(ValueError):
            random.sample(self.seq, 20)
        for element in random.sample(self.seq, 5):
            self.assertTrue(element in self.seq)

    def tearDown(self):
        pass

if __name__ == '__main__':
    # python -m unittest test
    unittest.main()

    # python -m unittest -v test
    #suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions)
    #unittest.TextTestRunner(verbosity=2).run(suite)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.