Skip to content

running tests including " from test.unit.elements.helper/task import ... . like test_generator.py #808

@Cudok

Description

@Cudok

description

When running a test, which tries to import objects from test.unit.xxxxx the interpreter returns the following error.
There is no error when the working directory is the bim2sim root folder. Then the interpreter find the objects in test.units.xxx, because the test folder is in the root folder.

error

ModuleNotFoundError: No module named 'test.unit' 

solutions

  1. run tests only from root directory
  • not user friendly
  1. add path to the testfolder to the PYTHON SYS path - more complex setup/installation
  2. make the test.unit objects part of the bim2sim framewoke
  • attention python includes a built-in module called test

solution 4: part of bim2sim framework

  • but for import TestStandardLibraryExports the absolute path "test.unit.xxx " is still used
  • make folder called testsuite into bim2sim.bim2sim
  • put elements.helper.py into bim2sim/bim2sim/testsuite
  • put class TestTask from test.unit.tasks.init.py into testsuite.init.py
  • adapt all test which load:
    • helpers
      • hvac/test_export.py
      • graphs/test_hvacgraph.py
      • mapping/test_attribute.py
      • hvac/test_dead_ends.py
      • hvac/test_expansiontank.py
      • tasks/init.py
      • bps/test_enrich_material.py
      • bps/test_enrich_use_cond.py
      • elements/test_elements.py
      • aggregation/test_underfloorheating.py
      • aggregation/test_aggregation.py
      • aggregation/test_consumer_distributor.py
      • aggregation/test_parallelpumps.py
      • aggregation/test_generator.py
      • aggregation/test_consumer.py
      • aggregation/test_pipestrand.py
      • unit/test_sim_settings.py
    • TestTask
      • hvac/test_export.py
      • bps/test_enrich_material.py
      • bps/test_enrich_use_cond.py

@sfreund1 and @veronikarichter I think the described changes make the test environment more clear. Do you see some disadvantage?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions