import time

from django.conf import settings

from slowpoke.models import *


class time_my_test(object):

    def __init__(self, standard, *args, **kwargs):
        settings.CURRENT_SLOWPOKE_STANDARD = standard

    def __call__(self, func):

        def to_time(*args, **kwargs):
            ts = time.time()
            result = func(*args, **kwargs)
            te = time.time()

            # check this against TIME_STANDARDS for the level of function. Log if it was too slow.
            sr = TestSuiteRun.objects.using('slowpokelogs').get(pk=settings.CURRENT_SLOWPOKE_RUN)
            tr = TestRun()
            tr.suite_run = sr
            tr.test_standard = settings.CURRENT_SLOWPOKE_STANDARD
            tr.function_name = str(func.__name__)
            tr.args = str(args)
            tr.kwargs = str(kwargs)
            tr.runtime_ms = (te - ts) * 1000
            tr.save(using='slowpokelogs')
            return result
        return to_time

import time

from django.conf import settings

from slowpoke.models import *


class time_my_test(object):

    def __init__(self, standard, *args, **kwargs):
        self.CURRENT_SLOWPOKE_STANDARD = standard

    def __call__(self, func):

        def to_time(*args, **kwargs):
            ts = time.time()
            result = func(*args, **kwargs)
            te = time.time()

            # check this against TIME_STANDARDS for the level of function. Log if it was too slow.
            sr = TestSuiteRun.objects.using('slowpokelogs').get(pk=settings.CURRENT_SLOWPOKE_RUN)
            tr = TestRun()
            tr.suite_run = sr
            tr.test_standard = self.CURRENT_SLOWPOKE_STANDARD
            tr.function_name = str(func.__name__)
            tr.args = str(args)
            tr.kwargs = str(kwargs)
            tr.runtime_ms = (te - ts) * 1000
            tr.save(using='slowpokelogs')
            return result
        return to_time

Store the standard on the class, not in settings - or else it's captured incorrectly as things process.
Store the standard on the class, not in settings - or else it's captured incorrectly as things process.
  import time
  
  from django.conf import settings
  
  from slowpoke.models import *
  
  
  class time_my_test(object):
  
      def __init__(self, standard, *args, **kwargs):
-         settings.CURRENT_SLOWPOKE_STANDARD = standard
+         self.CURRENT_SLOWPOKE_STANDARD = standard
  
      def __call__(self, func):
  
          def to_time(*args, **kwargs):
              ts = time.time()
              result = func(*args, **kwargs)
              te = time.time()
  
              # check this against TIME_STANDARDS for the level of function. Log if it was too slow.
              sr = TestSuiteRun.objects.using('slowpokelogs').get(pk=settings.CURRENT_SLOWPOKE_RUN)
              tr = TestRun()
              tr.suite_run = sr
-             tr.test_standard = settings.CURRENT_SLOWPOKE_STANDARD
+             tr.test_standard = self.CURRENT_SLOWPOKE_STANDARD
              tr.function_name = str(func.__name__)
              tr.args = str(args)
              tr.kwargs = str(kwargs)
              tr.runtime_ms = (te - ts) * 1000
              tr.save(using='slowpokelogs')
              return result
          return to_time
  
Store the standard on the class, not in settings - or else it's captured incorrectly as things process.
## Code Before:
import time

from django.conf import settings

from slowpoke.models import *


class time_my_test(object):

    def __init__(self, standard, *args, **kwargs):
        settings.CURRENT_SLOWPOKE_STANDARD = standard

    def __call__(self, func):

        def to_time(*args, **kwargs):
            ts = time.time()
            result = func(*args, **kwargs)
            te = time.time()

            # check this against TIME_STANDARDS for the level of function. Log if it was too slow.
            sr = TestSuiteRun.objects.using('slowpokelogs').get(pk=settings.CURRENT_SLOWPOKE_RUN)
            tr = TestRun()
            tr.suite_run = sr
            tr.test_standard = settings.CURRENT_SLOWPOKE_STANDARD
            tr.function_name = str(func.__name__)
            tr.args = str(args)
            tr.kwargs = str(kwargs)
            tr.runtime_ms = (te - ts) * 1000
            tr.save(using='slowpokelogs')
            return result
        return to_time

## Instruction:
Store the standard on the class, not in settings - or else it's captured incorrectly as things process.
## Code After:
import time

from django.conf import settings

from slowpoke.models import *


class time_my_test(object):

    def __init__(self, standard, *args, **kwargs):
        self.CURRENT_SLOWPOKE_STANDARD = standard

    def __call__(self, func):

        def to_time(*args, **kwargs):
            ts = time.time()
            result = func(*args, **kwargs)
            te = time.time()

            # check this against TIME_STANDARDS for the level of function. Log if it was too slow.
            sr = TestSuiteRun.objects.using('slowpokelogs').get(pk=settings.CURRENT_SLOWPOKE_RUN)
            tr = TestRun()
            tr.suite_run = sr
            tr.test_standard = self.CURRENT_SLOWPOKE_STANDARD
            tr.function_name = str(func.__name__)
            tr.args = str(args)
            tr.kwargs = str(kwargs)
            tr.runtime_ms = (te - ts) * 1000
            tr.save(using='slowpokelogs')
            return result
        return to_time
