Python Forum
spread same class into separate files in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
spread same class into separate files in python
#1
I have some automated test written in python. There is file named TestSteps.py that holds all the test methods. The file is getting too big holding too many methods. It looks like this

#TestSteps.py

import myModules

class Steps:
    @staticmethod
    def test1(self):
        ...
    @staticmethod
    def test2(self):
        ...
    @staticmethod
    def testX(self):
The file has now too many methods and I need to add more so I was thinking to split them into multiple files, for example TestSteps1, TestSteps2 etc. and inside TestSteps to import them like this:

#TestSteps.py    

import TestSteps1
reload(TestSteps1)
from TestSteps1 import *
...
import TestStepsX
reload(TestStepsX)
from TestStepsX import *
I need to have all these test files 'stored' under TestSteps.py because of how everything is configured, how the test are executed etc. With the approach I've tried above only the tests from first file are executed, the rest are not found.

So how can I spread for example 'class Steps' into multiple files? Or how can I import all my test method from different files into a central files that would be 'TestSteps.py'?
Reply


Messages In This Thread
spread same class into separate files in python - by asheru93 - Jun-19-2019, 01:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Class test : good way to split methods into several files paul18fr 4 522 Jan-30-2024, 11:46 AM
Last Post: Pedroski55
  Split Bytearray into separate Files by Hex delimter lastyle 5 2,744 Mar-09-2023, 07:49 AM
Last Post: bowlofred
  Python Split json into separate json based on node value CzarR 1 5,702 Jul-08-2022, 07:55 PM
Last Post: Larz60+
  importing functions from a separate python file in a separate directory Scordomaniac 3 1,402 May-17-2022, 07:49 AM
Last Post: Pedroski55
  How to save files in a separate directory Scordomaniac 3 2,009 Mar-16-2022, 10:17 AM
Last Post: Gribouillis
  Separate text files and convert into csv marfer 6 2,937 Dec-10-2021, 12:09 PM
Last Post: marfer
  Pythonic way to handle/spread alerts class in multiple modules psolar 11 4,701 Feb-12-2020, 04:11 PM
Last Post: psolar
  write each line of a text file into separate text files and save with different names Shameendra 3 2,818 Feb-20-2019, 09:07 AM
Last Post: buran
  instance of a class in different files DionisiO 2 2,486 Jan-21-2019, 09:38 PM
Last Post: DionisiO
  Running a python tool transforming xml files into epub files silfer 7 5,470 May-10-2018, 03:49 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020