Introduction to pytest

Introduction to pytest

Slides for my EuroPython 2014 talk on pytest

0aa514c079b74c6655e6a8bf1073c878?s=128

Andreas Pelme

July 23, 2014
Tweet

Transcript

  1. 3.
  2. 5.
  3. 8.

    %FNP#FGPSF import  unittest   ! ! def  upper_reverse(text):    

         return  ''.join(reversed(text.upper()))   ! ! class  TestUpperReverse(unittest.TestCase):          def  test_upper_reverse(self):                  self.assertEqual(upper_reverse('hello'),  'OLLEH')
  4. 9.

    %FNP"GUFS def  upper_reverse(text):          return  ''.join(reversed(text.upper()))  

    ! ! def  test_upper_reverse():          assert  upper_reverse('hello')  ==  'OLLEH'
  5. 20.

    4LJQQJOHUFTUT import  pytest   import  sys   ! ! @pytest.mark.skipif(sys.platform

     ==  'darwin',                                          reason='Feature  Y  not  supported  on  OS  X')   def  test_non_osx():          pass
  6. 23.

    %FQFOEFODZJOKFDUJPOPGUFTUIFMQFS import  pytest   from  selenium.webdriver  import  Firefox   !

    @pytest.fixture   def  webdriver(request):          driver  =  Firefox()          request.addfinalizer(driver.quit)          return  driver   ! def  test_nix_website_title(webdriver):          webdriver.get('https://nixos.org/nix/')          assert  'Nix'  in  webdriver.title   ! def  test_pytest_website_title(webdriver):          webdriver.get('http://pytest.org/latest/')