Skip to content

Commit f44e97f

Browse files
author
Anton Schulte
committed
fix testing
1 parent 7b81938 commit f44e97f

7 files changed

Lines changed: 46 additions & 21 deletions

File tree

vunit/library.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import logging
1414
from typing import cast
1515
from vunit.design_unit import Entity, VHDLDesignUnit
16-
from vunit.source_file import SourceFile, VHDLSourceFile, VerilogSourceFile
16+
from typing import TYPE_CHECKING
17+
18+
if TYPE_CHECKING:
19+
from vunit.source_file import SourceFile, VHDLSourceFile, VerilogSourceFile
1720
from vunit.vhdl_standard import VHDLStandard
1821

1922
LOGGER = logging.getLogger(__name__)
@@ -49,7 +52,7 @@ def __init__(self, name: str, directory: str, vhdl_standard: VHDLStandard, is_ex
4952

5053
self._is_external = is_external
5154

52-
def add_source_file(self, source_file: SourceFile) -> SourceFile:
55+
def add_source_file(self, source_file: "SourceFile") -> "SourceFile":
5356
"""
5457
Add source file to library unless it exists
5558

vunit/ui/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from vunit.test.list import TestList
2424

2525
from vunit.ui.preprocessor import Preprocessor
26-
from vunit.source_file import SourceFile as Source_File
2726

2827
from ..database import PickledDataBase, DataBase
2928
from .. import ostools
@@ -48,6 +47,11 @@
4847
from .library import Library, LibraryList
4948
from .results import Results
5049

50+
from typing import TYPE_CHECKING
51+
52+
if TYPE_CHECKING:
53+
from vunit.source_file import SourceFile as Source_File
54+
5155

5256
class VUnit(object): # pylint: disable=too-many-instance-attributes, too-many-public-methods
5357
"""
@@ -943,7 +947,7 @@ def _compile(self, simulator_if: SimulatorInterface) -> None:
943947
target_files=target_files,
944948
)
945949

946-
def _get_testbench_files(self, simulator_if: Union[None, SimulatorInterface]) -> list[Source_File]:
950+
def _get_testbench_files(self, simulator_if: Union[None, SimulatorInterface]) -> list["Source_File"]:
947951
"""
948952
Return the list of all test bench files for the currently selected tests to run
949953
"""

vunit/ui/library.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from vunit.sim_if import OptionType
1515

1616
from vunit.test.bench_list import TestBenchList
17-
from vunit.ui import VUnit
1817
from vunit.ui.preprocessor import Preprocessor
1918
from ..vhdl_standard import VHDL, VHDLStandard
2019
from ..project import Project
@@ -25,13 +24,18 @@
2524
from .testbench import TestBench
2625
from .packagefacade import PackageFacade
2726

27+
from typing import TYPE_CHECKING
28+
29+
if TYPE_CHECKING:
30+
from vunit.ui import VUnit
31+
2832

2933
class Library(object):
3034
"""
3135
User interface of a library
3236
"""
3337

34-
def __init__(self, library_name: str, parent: VUnit, project: Project, test_bench_list: TestBenchList) -> None:
38+
def __init__(self, library_name: str, parent: "VUnit", project: Project, test_bench_list: TestBenchList) -> None:
3539
self._library_name = library_name
3640
self._parent = parent
3741
self._project = project

vunit/ui/packagefacade.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@
1212
from typing import Optional, Union
1313
from vunit.design_unit import DesignUnit
1414

15-
from vunit.ui import VUnit
1615
from vunit.ui.source import SourceFileList
1716
from ..com import codec_generator
17+
from typing import TYPE_CHECKING
18+
19+
if TYPE_CHECKING:
20+
from vunit.ui import VUnit
1821

1922

2023
class PackageFacade(object):
2124
"""
2225
User interface of a Package
2326
"""
2427

25-
def __init__(self, parent: VUnit, library_name: str, package_name: str, design_unit: DesignUnit) -> None:
28+
def __init__(self, parent: "VUnit", library_name: str, package_name: str, design_unit: DesignUnit) -> None:
2629
self._parent = parent
2730
self._library_name = library_name
2831
self._package_name = package_name

vunit/ui/results.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111
from pathlib import Path
1212
from typing import Any, Dict, Optional, Union
13+
from typing import TYPE_CHECKING
1314

14-
from vunit.sim_if import SimulatorInterface
15-
from vunit.test.report import TestReport
15+
if TYPE_CHECKING:
16+
from vunit.sim_if import SimulatorInterface
17+
from vunit.test.report import TestReport
1618
from .common import TEST_OUTPUT_PATH
1719

1820

@@ -21,7 +23,7 @@ class Results(object):
2123
Gives access to results after running tests
2224
"""
2325

24-
def __init__(self, output_path: str, simulator_if: SimulatorInterface, report: TestReport) -> None:
26+
def __init__(self, output_path: str, simulator_if: "SimulatorInterface", report: "TestReport") -> None:
2527
self._output_path = output_path
2628
self._simulator_if = simulator_if
2729
self._report = report

vunit/ui/source.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@
1212

1313
from vunit.project import Project
1414
from vunit.sim_if import OptionType
15-
from vunit.ui import VUnit
16-
from vunit.ui.library import Library
1715
from .. import ostools
18-
from vunit.source_file import SourceFile as Source_File, VHDLSourceFile
16+
from typing import TYPE_CHECKING
17+
18+
if TYPE_CHECKING:
19+
from vunit.source_file import SourceFile as Source_File
20+
from vunit.ui import VUnit
21+
from vunit.ui.library import Library
1922

2023

2124
class SourceFile(object):
2225
"""
2326
A single file
2427
"""
2528

26-
def __init__(self, source_file: Source_File, project: Project, ui: VUnit) -> None:
29+
def __init__(self, source_file: "Source_File", project: Project, ui: "VUnit") -> None:
2730
self._source_file = source_file
2831
self._project = project
2932
self._ui = ui
@@ -41,13 +44,16 @@ def vhdl_standard(self) -> Optional[str]:
4144
The VHDL standard applicable to the file,
4245
None if not a VHDL file
4346
"""
47+
# Import here to avoid circular import problems
48+
from vunit.source_file import VHDLSourceFile
49+
4450
if isinstance(self._source_file, VHDLSourceFile):
4551
return str(self._source_file.get_vhdl_standard())
4652

4753
return None
4854

4955
@property
50-
def library(self) -> Library:
56+
def library(self) -> "Library":
5157
"""
5258
The library of the source file
5359
"""
@@ -85,7 +91,7 @@ def get_compile_option(self, name: str) -> OptionType:
8591
"""
8692
return self._source_file.get_compile_option(name)
8793

88-
def add_dependency_on(self, source_file: Union[Iterable[Source_File], Source_File]) -> None:
94+
def add_dependency_on(self, source_file: Union[Iterable["Source_File"], "Source_File"]) -> None:
8995
"""
9096
Add manual dependency of this file other file(s)
9197
@@ -142,7 +148,7 @@ def add_compile_option(self, name: str, value: OptionType) -> None:
142148
for source_file in self:
143149
source_file.add_compile_option(name, value)
144150

145-
def add_dependency_on(self, source_file: Source_File) -> None:
151+
def add_dependency_on(self, source_file: "Source_File") -> None:
146152
"""
147153
Add manual dependency of these files on other file(s)
148154

vunit/ui/testbench.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
from typing import Any, Callable, Optional, cast
1313

1414
from vunit.sim_if import OptionType
15-
from vunit.ui.library import Library
1615
from .common import lower_generics
1716
from .test import Test
1817
from vunit.test.bench import TestBench as Test_Bench
18+
from typing import TYPE_CHECKING
19+
20+
if TYPE_CHECKING:
21+
from vunit.ui.library import Library
1922

2023

2124
class TestBench(object):
@@ -25,7 +28,7 @@ class TestBench(object):
2528
bench will apply that option to all test cases belonging to that test bench.
2629
"""
2730

28-
def __init__(self, test_bench: Test_Bench, library: Library) -> None:
31+
def __init__(self, test_bench: Test_Bench, library: "Library") -> None:
2932
self._test_bench = test_bench
3033
self._library = library
3134

@@ -37,7 +40,7 @@ def name(self) -> str:
3740
return self._test_bench.name
3841

3942
@property
40-
def library(self) -> Library:
43+
def library(self) -> "Library":
4144
"""
4245
:returns: The library that contains this test bench
4346
"""

0 commit comments

Comments
 (0)