Ejemplo n.º 1
0
 def test_publishes_test_ended_with_test_name_on_clean_exit(self):
     name = "Shem"
     with test(name=name):
         pass
     expect(self.last_message()).to(
         contain_all_items_in({
             "event": TestEvent.test_ended,
             "test_name": name
         }))
Ejemplo n.º 2
0
 def test_publishes_test_skipped_with_exception(self):
     expected = TestSkipped("No way")
     try:
         with test(name="something"):
             raise expected
     except TestSkipped:
         pass  # unexpected but covered by another test
     expect(self.fake_broker.message_for_event(TestEvent.test_skipped)).to(
         contain_key_with_value("exception", expected))
Ejemplo n.º 3
0
 def test_publishes_test_skipped_with_test_name(self):
     name = "skippy"
     try:
         with test(name=name):
             raise TestSkipped("I prefer not to")
     except TestSkipped:
         pass  # unexpected but covered by another test
     expect(self.fake_broker.message_for_event(TestEvent.test_skipped)).to(
         contain_key_with_value("test_name", name))
Ejemplo n.º 4
0
 def test_publishes_test_failed_with_exception(self):
     expected = AssertionError("coulda")
     try:
         with test(name="something"):
             raise expected
     except AssertionError:
         pass  # unexpected but covered by another test
     expect(self.fake_broker.message_for_event(TestEvent.test_failed)).to(
         contain_key_with_value("exception", expected))
Ejemplo n.º 5
0
 def test_publishes_test_failed_with_test_name(self):
     name = "chump"
     try:
         with test(name=name):
             raise AssertionError("intentional")
     except AssertionError:
         pass  # unexpected but covered by another test
     expect(self.fake_broker.message_for_event(TestEvent.test_failed)).to(
         contain_key_with_value("test_name", name))
Ejemplo n.º 6
0
 def test_publishes_test_erred_with_exception(self):
     expected = FakeException("Seriously?")
     try:
         with test(name="something"):
             raise expected
     except FakeException:
         pass  # unexpected but covered by another test
     expect(self.fake_broker.message_for_event(TestEvent.test_erred)).to(
         contain_key_with_value("exception", expected))
Ejemplo n.º 7
0
 def test_publishes_test_started_with_test_name_on_entry(self):
     name = "Shem"
     with test(name=name):
         pass
     expect(self.fake_broker.messages).not_to(be_empty)
     expect(self.fake_broker.messages[0]).to(
         contain_all_items_in({
             "event": TestEvent.test_started,
             "test_name": name
         }))
Ejemplo n.º 8
0
 def test_publishes_test_ended_with_test_name_on_exit_after_err(self):
     name = "something"
     try:
         with test(name=name):
             raise Exception("intentional")
     except Exception:
         pass  # Unexpected, but covered by another test
     expect(self.last_message()).to(
         contain_all_items_in({
             "event": TestEvent.test_ended,
             "test_name": name
         }))
from expects import expect, contain
from questions_three.scaffolds.test_script import test, test_suite
from questions_three_selenium.browser.browser import Browser

with test_suite("SeleniumExample"):

    browser = Browser()
    browser.get("http://www.example.com")

    # This test will probably pass
    with test("Verify text contains example domain"):
        html = browser.find_unique_element(tag_name="html")
        expect(html.text.lower()).to(contain("example domain"))

    # This test should fail unless the Spinach Inquisition takes over example.com
    with test("Verify text contains Cardinal Biggles"):
        html = browser.find_unique_element(tag_name="html")
        expect(html.text.lower()).to(contain("Cardinal Biggles"))
Ejemplo n.º 10
0
from questions_three.scaffolds.test_script import precondition, skip, test, test_suite

with test_suite("ExampleSuite"):

    with test("A passing test"):
        assert True, "That was easy"

    with test("A failing test"):
        assert False, "Failing is easy too"

    with test("An errant test"):
        raise RuntimeError("Intentional error")

    with test("A skipped test"):
        skip("Let's not run this test.  It's rather silly.")

    with test("A test that skips because its precondition is not met"):
        precondition(False)

    with test("A test that runs because its precondition is met"):
        precondition(True)
Ejemplo n.º 11
0
 def attempt():
     with test(name="spam"):
         raise Exception("oops")