Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8586003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:12:16+00:00 2026-06-11T22:12:16+00:00

I have the following decorator in a base class: class BaseTests(TestCase): @staticmethod def check_time(self,

  • 0

I have the following decorator in a base class:

class BaseTests(TestCase):
    @staticmethod
    def check_time(self, fn):
        @wraps(fn)
        def test_wrapper(*args,**kwargs):
            # do checks ...
        return test_wrapper

And the following class inheriting from BaseTests:

from path.base_posting import BaseTests
from path.base_posting.BaseTests import check_time  # THIS LINE DOES NOT WORK!

class SpecificTest(BaseTests):

    @check_time # use the decorator
    def test_post(self):
        # do testing ...

I would like to use the decorator in SpecificTest as above, without having to use BaseTests.check_time, because in the original code they have long names, and I have to use it in many places. Any ideas?

EDIT:
I decided to make check_time an independent function in BaseTests file, and simply import

from path.base_posting import BaseTests, check_time
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:12:18+00:00Added an answer on June 11, 2026 at 10:12 pm

    Simply put

    check_time = BaseTests.check_time
    

    in your second module:


    from module_paths.base_posting import BaseTests
    check_time = BaseTests.check_time
    
    class SpecificTest(BaseTests):
    
        @check_time # use the decorator
        def test_post(self):
            # do testing ...
    

    You may also want to reconsider making check_time a staticmethod, since it appears your use case employs it more as a stand-alone function than as a staticmethod.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following: def with_connection(f): def decorated(*args, **kwargs): f(get_connection(...), *args, **kwargs)
I have some questions regarding the following code: 1 class Test(object): 2 def __init__(self):
I have the following decorator with parameters: from functools import wraps def pdecor(p): def
I have the following decorator and view which works fine. Decorator def event_admin_only(func): Checks
I have the following class which is a decorator for an IDisposable object (I
I have the following decorator inside a module: class CachedProperty(object): Decorator that lazy-loads the
I have this base class having the following interface: abstract class Base { abstract
I have multiple classes of the following structure: class Thing(Base): id = Column(Integer, primary_key=True)
I have the following code; what should be added to the decorator class to
I have the following html structure: <div class=decorator> <div class=EC_MyICHP_Item> <div class=text> <h3><a target=_blank

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.