Package tlib :: Package base :: Module PytestTester |
[hide private]
[frames] | no frames]

# Source Code for Module tlib.base.PytestTester

     1  import pytest
     2  import sys
     3  from TestHelper import Singleton
     4  import ctypes
     5
     6  # noinspection PyMethodParameters
     7  # noinspection PyUnresolvedReferences
     8 -class PytestTester(object):
     9      __metaclass__ = Singleton
    10      test_logger = None
    11      tlib_logger = None
    12
    13      @pytest.fixture(scope='function', autouse=True)
    14 -    def log(self, request, test_logger):
    15          test_logger.info("======================== START %s ========================" % request.keywords.node.name)
    16
    17          def log_end():
    18              test_logger.info("======================== END %s ========================" % request.keywords.node.name)
    19
    20          request.addfinalizer(log_end)
    21
    22      # noinspection PyPep8Naming
    23      @pytest.fixture(scope='class', autouse=True)
    24 -    def initialize_PytestTester_class(self, request, test_logger, tlib_logger):
    25          """
    26          @type request: FixtureRequest
    27          @type test_logger: logging
    28          @type tlib_logger: logging
    29          """
    30          #Store an instance of browser and loggers to be used from code that doesn't have access to this information
    31          setattr(PytestTester, 'test_logger', test_logger)
    32          setattr(PytestTester, 'tlib_logger', tlib_logger)
    33
    34      @pytest.fixture()
    35 -    def ignore_windows_GPF_dialog(self):
    36          """
    37          Ignores the GPF dialog when a windows application crashes so that the test can continue when
    38              the intention is that the application crashes
    39          """
    40          if sys.platform.startswith("win"):
    41              # Don't display the Windows GPF dialog if the invoked program dies.
    42              SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN
    43              ctypes.windll.kernel32.SetErrorMode(SEM_NOGPFAULTERRORBOX);
    44              subprocess_flags = 0x8000000 #win32con.CREATE_NO_WINDOW?
    45          else:
    46              subprocess_flags = 0
    47