# Path: nosedjango/plugins/base_plugin.py
# class Plugin(NosePlugin):
#     django_plugin = True
#     _unique_token = None
# 
#     def get_unique_token(self):
#         """
#         Get a unique token for usage in differentiating test runs that need to
#         run in parallel.
#         """
#         if self._unique_token is None:
#             self._unique_token = self._random_token()
# 
#         return self._unique_token
# 
#     def _random_token(self, bits=128):
#         """
#         Generates a random token, using the url-safe base64 alphabet.
#         The "bits" argument specifies the bits of randomness to use.
#         """
#         alphabet = string.ascii_letters + string.digits + '-_'
#         # alphabet length is 64, so each letter provides lg(64) = 6 bits
#         num_letters = int(math.ceil(bits / 6.0))
#         return ''.join(random.choice(alphabet) for i in range(num_letters))


import os
import time
from django.core.handlers.wsgi import WSGIHandler
from nosedjango.plugins.base_plugin import Plugin
        from django.conf import settings
        from django.contrib.staticfiles.handlers import StaticFilesHandler
        from cherrypy.wsgiserver import CherryPyWSGIServer
        from threading import Thread
        Plugin.__init__(self)
        self.server_started = False
        self.server_thread = None

    def options(self, parser, env=os.environ):
        Plugin.options(self, parser, env)

    def configure(self, options, config):
        Plugin.configure(self, options, config)

    def startTest(self, test):

        if not self.server_started and \
           getattr(test, 'start_live_server', False):

            self.start_server(
                address=getattr(
                    settings,
                    "LIVE_SERVER_ADDRESS",
                    DEFAULT_LIVE_SERVER_ADDRESS,
                ),
                port=int(getattr(
                    settings,
                    "LIVE_SERVER_PORT",
                    DEFAULT_LIVE_SERVER_PORT,
                ))
            )
            self.server_started = True

    def finalize(self, result):

# Path: nosedjango/plugins/base_plugin.py
# class Plugin(NosePlugin):
#     django_plugin = True
#     _unique_token = None
# 
#     def get_unique_token(self):
#         """
#         Get a unique token for usage in differentiating test runs that need to
#         run in parallel.
#         """
#         if self._unique_token is None:
#             self._unique_token = self._random_token()
# 
#         return self._unique_token
# 
#     def _random_token(self, bits=128):
#         """
#         Generates a random token, using the url-safe base64 alphabet.
#         The "bits" argument specifies the bits of randomness to use.
#         """
#         alphabet = string.ascii_letters + string.digits + '-_'
#         # alphabet length is 64, so each letter provides lg(64) = 6 bits
#         num_letters = int(math.ceil(bits / 6.0))
#         return ''.join(random.choice(alphabet) for i in range(num_letters))


# Path: nosedjango/plugins/cherrypy_plugin.py
import os
import time
from django.core.handlers.wsgi import WSGIHandler
from nosedjango.plugins.base_plugin import Plugin
        from django.conf import settings
        from django.contrib.staticfiles.handlers import StaticFilesHandler
        from cherrypy.wsgiserver import CherryPyWSGIServer
        from threading import Thread

        Plugin.__init__(self)
        self.server_started = False
        self.server_thread = None

    def options(self, parser, env=os.environ):
        Plugin.options(self, parser, env)

    def configure(self, options, config):
        Plugin.configure(self, options, config)

    def startTest(self, test):

        if not self.server_started and \
           getattr(test, 'start_live_server', False):

            self.start_server(
                address=getattr(
                    settings,
                    "LIVE_SERVER_ADDRESS",
                    DEFAULT_LIVE_SERVER_ADDRESS,
                ),
                port=int(getattr(
                    settings,
                    "LIVE_SERVER_PORT",
                    DEFAULT_LIVE_SERVER_PORT,
                ))
            )
            self.server_started = True

    def finalize(self, result):

        self.stop_test_server()