• 课间练习1

    import pytest
    import time
    import json
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.support import expected_conditions
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities


    class TestHgwz():
    def setup_method(self, method):
    self.driver = webdriver.Chrome()
    self.vars = {}

    def teardown_method(self, method):
    self.driver.quit()

    def test_testhgwz(self):
    self.driver.get("https://testerhome.com/")
    self.driver.set_window_size(1398, 876)
    self.driver.find_element(By.LINK_TEXT, "社团").click()
    self.driver.find_element(By.LINK_TEXT, "霍格沃兹测试学院").click()
    self.driver.find_element(By.CSS_SELECTOR, ".topic-21848 .title > a").click()

  • 十一期_Python 测试_20191222 at December 22, 2019

    课后作业2

    import pytest
    from test_pytest.div import div


    @pytest.mark.parametrize("num1,num2,except_result", {(10, 2, 5),
    (1, 1, 1),
    (1000000000000, 10, 100000000000),
    (0, 10, 0),
    (-9, 3, -3),
    (-1, 1, -1),
    (-500, -50, 10)
    })
    def test_div_int(num1, num2, except_result):
    assert div(num1, num2) == except_result

    @pytest.mark.parametrize("num1,num2,except_result", {(10, 2.0, 5.0),
    (9.9, 3, 3.3),
    (1, 1.0, 1.0),
    (20.8, 4.2, 5.4),
    (1000000.00, 100, 10000.0),
    (-1.0, 1, -1.0),
    (-100, 10, -10),
    (-5, -2, 2.5)
    })
    def test_div_float(num1, num2, except_result):
    assert div(num1, num2) == except_result

    @pytest.mark.parametrize("num1,num2,except_result", {('abc', 1, None),
    (888, 'a', None),
    ('b', 'b', None),
    (True, False, None)
    })
    def test_div_exception(num1, num2, except_result):
    assert div(num1, num2) == except_result

    @pytest.mark.parametrize("num1,num2,except_result", {(1, 0, ZeroDivisionError),
    (9.0, 0, ZeroDivisionError),
    (100, 0.0, ZeroDivisionError)
    })
    def test_div_zero(num1, num2, except_result):
    with pytest.raises(except_result):
    div(num1, num2)



    SDET11-LY user$ pytest --junitxml=test_pytest/junit.xml --alluredir=test_pytest/allure_results test_pytest/
    SDET11-LY user$ allure serve test_pytest/allure_results/