1111import timing
1212import typed_astunparse
1313
14- from transpyle .general .code_reader import CodeReader
15- from transpyle .general .binder import Binder
16- from transpyle .cpp .parser import CppParser
17- from transpyle .cpp .ast_generalizer import CppAstGeneralizer
18- from transpyle .cpp .unparser import Cpp14Unparser
19- from transpyle .cpp .compiler import CppSwigCompiler
20- from transpyle .cpp .compiler_interface import GppInterface
14+ from transpyle .general import AstGeneralizer , Binder , CodeReader , Parser
15+
16+ try :
17+ from transpyle .cpp .parser import CppParser
18+ except ImportError :
19+ pass
20+ try :
21+ from transpyle .cpp .ast_generalizer import CppAstGeneralizer
22+ except ImportError :
23+ pass
24+ try :
25+ from transpyle .cpp .unparser import Cpp14Unparser
26+ except ImportError :
27+ pass
28+ try :
29+ from transpyle .cpp .compiler import CppSwigCompiler
30+ except ImportError :
31+ pass
32+ try :
33+ from transpyle .cpp .compiler_interface import GppInterface
34+ except ImportError :
35+ pass
2136
2237from .common import \
2338 PERFORMANCE_RESULTS_ROOT , EXAMPLES_ROOT , EXAMPLES_ROOTS , \
2944_TIME = timing .get_timing_group (__name__ )
3045
3146
47+ @unittest .skipIf (Parser .find ('C++' ) is None , 'skipping due to missing C++ language support' )
3248class ParserTests (unittest .TestCase ):
3349
3450 @execute_on_language_examples ('cpp14' )
@@ -53,6 +69,7 @@ def test_try_parse_invalid(self):
5369 _LOG .debug ('%s' , err .exception )
5470
5571
72+ @unittest .skipIf (AstGeneralizer .find ('C++' ) is None , 'skipping due to missing C++ language support' )
5673class AstGeneralizerTests (unittest .TestCase ):
5774
5875 @execute_on_language_examples ('cpp14' )
@@ -71,6 +88,7 @@ def test_generalize_examples(self, input_path):
7188 _LOG .debug ('%s' , typed_astunparse .unparse (syntax ))
7289
7390
91+ @unittest .skipIf (Unparser .find ('C++' ) is None , 'skipping due to missing C++ language support' )
7492class UnparserTests (unittest .TestCase ):
7593
7694 @execute_on_language_examples ('cpp14' )
@@ -97,6 +115,7 @@ def test_unparse_examples(self, input_path):
97115 _LOG .info ('unparsed "%s" in %fs' , input_path , timer .elapsed )
98116
99117
118+ @unittest .skipIf (Compiler .find ('C++' ) is None , 'skipping due to missing C++ language support' )
100119class CompilerTests (unittest .TestCase ):
101120
102121 def test_cpp_paths_exist (self ):
0 commit comments