SSTTestCase is run twice in python unittest testsuite?

Asked by Ari on 2013-08-25

It seems that SSTTestCase is executed twice when it's added in unittest testsuite.

I have a test:

from sst.actions import go_to, assert_title_contains
from sst import cases

class TestUbuntu(cases.SSTTestCase):

    def test_homepages(self):

Which is added to following suite (testscenarios is used for multiple browser support in case of other browsers than Firefox):

import unittest
import xmlrunner
import testtools
from testscenarios import generate_scenarios
from sst import cases

from test_ubuntu import TestUbuntu

    from StringIO import StringIO
except ImportError:
    from io import StringIO

suite = unittest.TestSuite()
runner = xmlrunner.XMLTestRunner(stream=StringIO())

mytests = unittest.TestSuite()

for test in testtools.iterate_tests(mytests):
        test.scenarios = [('Firefox', dict(browser_factory=cases.browsers.FirefoxFactory(), xserver_headless=True, screenshots_on=True))]


When the suite is being executed (python the test is run twice. If I don't add the test to mytests, the test is executed once, but XML test result report is not being produced.

Is this a bug or feature? Should I be executing SSTTestCases only via SST-run?

Question information

English Edit question
selenium-simple-test Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Ari (arzzka) said : #1

SST version was 0.2.4.

Vincent Ladeuil (vila) said : #2

SSTTestCase is meant to be used as a regular unittest test case, so it doesn't require sst-run.

I can't diagnose what went wrong in your case but I suspect it has to do with the way you build and run your test suite rather than sst itself.

Ari (arzzka) said : #3

Even when I simplify the suite to be:

import unittest
import xmlrunner
from sst import cases

from test_ubuntu import TestUbuntu
from StringIO import StringIO

runner = xmlrunner.XMLTestRunner(stream=StringIO())
loader = unittest.TestLoader()
suite = loader.loadTestsFromTestCase(TestUbuntu)

The test is run twice.

Vincent Ladeuil (vila) said : #4

What does suite.countTestCases() says ?

Which tests are present in suite._tests ?

Ari (arzzka) said : #5

It starts to look like my Eclipse/Pydev run configuration is somehow screwed, because it does not happen from command line after all. Let me try once more tomorrow on a different machine.

print suite.countTestCases()
print suite._tests

Console output from Eclipse:
Finding files... done.
Importing test modules ... 1
[<test_ubuntu.TestUbuntu.test_homepages id=0x978bc6c>]

So number of tests is 1 and suite._tests has only one case. Firefox pops up 2 times in Eclipse, not via command line.

Ari (arzzka) said : #6

Eclipse/Pydev run configs were messed up. This issue is solved.