← Back to team overview

sikuli-driver team mailing list archive

[Bug 1331976] Re: [request] get error while invoke unittest.main() --- cannot be used in Sikuli scripts

 

** Changed in: sikuli
       Status: In Progress => Won't Fix

** Changed in: sikuli
    Milestone: 2.0.0 => None

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1331976

Title:
  [request] get error while invoke unittest.main() --- cannot be used in
  Sikuli scripts

Status in Sikuli:
  Won't Fix

Bug description:
  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.
  Anyone have any sugesstion?

  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)

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1331976/+subscriptions


References