# Path: tests/base.py
# class TestCase(unittest.TestCase):
#     """Base class for testing wdom modules.
# 
#     This class is a sub class of the ``unittest.TestCase``. After all test
#     methods, reset wdom's global objects like document, application, and
#     elements. If you use ``tearDown`` method, do not forget to call
#     ``super().tearDown()``.
#     """
# 
#     def setUp(self) -> None:
#         """Reset WDOM states."""
#         super().setUp()
#         reset()
# 
#     def tearDown(self) -> None:
#         """Reset WDOM states."""
#         reset()
#         super().tearDown()
# 
#     def assertIsTrue(self, bl: bool) -> None:
#         """Check arg is exactly True, not truthy."""
#         self.assertIs(bl, True)
# 
#     def assertIsFalse(self, bl: bool) -> None:
#         """Check arg is exactly False, not falsy."""
#         self.assertIs(bl, False)
# 
# Path: tests/test_selenium/base.py
# def close_webdriver() -> None:
#     """Close WebDriver."""
#     global local_webdriver
#     if local_webdriver is not None:
#         local_webdriver.close()
#         local_webdriver = None
# 
# def get_webdriver() -> WebDriver:
#     """Return WebDriver of current process.
# 
#     If it is not started yet, start and return it.
#     """
#     if globals().get('local_webdriver') is None:
#         start_webdriver()
#     return local_webdriver


import sys
import os
import subprocess
import time
import unittest
from selenium.webdriver.common.utils import free_port
from ..base import TestCase
from .base import close_webdriver, get_webdriver



def tearDownModule():
    close_webdriver()


@unittest.skipIf('TRAVIS' in os.environ, 'skip selenium tests on Travis')
class BaseTestCase(object):
    module = ''

    def setUp(self):
        self.wd = get_webdriver()
        self.port = free_port()
        time.sleep(0.01)
        cmd = [sys.executable, '-m', self.module, '--port', str(self.port)]
        self.proc = subprocess.Popen(cmd, env=os.environ,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE,
                                     )
        self.url = 'http://localhost:{}'.format(self.port)
        time.sleep(1)
        self.wd.get(self.url)

    def tearDown(self):
        self.proc.terminate()
        self.proc.wait()
        super().tearDown()



# Path: tests/base.py
# class TestCase(unittest.TestCase):
#     """Base class for testing wdom modules.
# 
#     This class is a sub class of the ``unittest.TestCase``. After all test
#     methods, reset wdom's global objects like document, application, and
#     elements. If you use ``tearDown`` method, do not forget to call
#     ``super().tearDown()``.
#     """
# 
#     def setUp(self) -> None:
#         """Reset WDOM states."""
#         super().setUp()
#         reset()
# 
#     def tearDown(self) -> None:
#         """Reset WDOM states."""
#         reset()
#         super().tearDown()
# 
#     def assertIsTrue(self, bl: bool) -> None:
#         """Check arg is exactly True, not truthy."""
#         self.assertIs(bl, True)
# 
#     def assertIsFalse(self, bl: bool) -> None:
#         """Check arg is exactly False, not falsy."""
#         self.assertIs(bl, False)
# 
# Path: tests/test_selenium/base.py
# def close_webdriver() -> None:
#     """Close WebDriver."""
#     global local_webdriver
#     if local_webdriver is not None:
#         local_webdriver.close()
#         local_webdriver = None
# 
# def get_webdriver() -> WebDriver:
#     """Return WebDriver of current process.
# 
#     If it is not started yet, start and return it.
#     """
#     if globals().get('local_webdriver') is None:
#         start_webdriver()
#     return local_webdriver


# Path: tests/test_selenium/test_example_module.py
import sys
import os
import subprocess
import time
import unittest
from selenium.webdriver.common.utils import free_port
from ..base import TestCase
from .base import close_webdriver, get_webdriver




def tearDownModule():
    close_webdriver()


@unittest.skipIf('TRAVIS' in os.environ, 'skip selenium tests on Travis')
class BaseTestCase(object):
    module = ''

    def setUp(self):
        self.wd = get_webdriver()
        self.port = free_port()
        time.sleep(0.01)
        cmd = [sys.executable, '-m', self.module, '--port', str(self.port)]
        self.proc = subprocess.Popen(cmd, env=os.environ,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE,
                                     )
        self.url = 'http://localhost:{}'.format(self.port)
        time.sleep(1)
        self.wd.get(self.url)

    def tearDown(self):
        self.proc.terminate()
        self.proc.wait()
        super().tearDown()



class TestReverseText(BaseTestCase, TestCase):