Belle II Software
development
test_embedding_example.py
1
#!/usr/bin/env python3
2
3
10
11
import
os
12
import
sys
13
import
subprocess
14
import
unittest
15
from
basf2
import
find_file
16
from
b2test_utils
import
clean_working_directory
17
18
19
class
TestEmbedding
(unittest.TestCase):
20
"""Test to run the embedding example."""
21
22
@unittest.skipIf(not os.getenv('BELLE2_EXAMPLES_DATA_DIR')
,
23
"$BELLE2_EXAMPLES_DATA_DIR not found."
)
24
def
testEmbedding
(self):
25
"""
26
Test the embedding example.
27
"""
28
embedding_example = find_file('analysis/examples/embedding/embedding.py'
)
29
30
result = subprocess.run([
'basf2'
, embedding_example], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
31
if
result.returncode != 0:
32
# failure running tutorial so let's print the output
33
# on stderr so it's not split from output of unittest
34
# done like this since we don't want to decode/encode utf8
35
sys.stdout.buffer.write(result.stdout)
36
37
self.assertEqual(result.returncode, 0)
38
39
40
if
__name__ ==
'__main__'
:
41
with
clean_working_directory():
42
unittest.main()
test_embedding_example.TestEmbedding
Definition:
test_embedding_example.py:19
test_embedding_example.TestEmbedding.testEmbedding
def testEmbedding(self)
Definition:
test_embedding_example.py:24
analysis
tests
test_embedding_example.py
Generated on Fri Nov 8 2024 02:32:59 for Belle II Software by
1.9.6