|
10 | 10 | from bald.tests import BaldTestCase
|
11 | 11 | from rdflib import Graph
|
12 | 12 |
|
| 13 | +# a module level graph, to share for memory and performance |
| 14 | +thisGraph = [Graph()] |
| 15 | +loaded_boolean = [] |
| 16 | + |
13 | 17 |
|
14 | 18 | class Test(BaldTestCase):
|
15 | 19 | def setUp(self):
|
16 | 20 | self.cdl_path = os.path.join(os.path.dirname(__file__), 'CDL')
|
17 |
| - self.ttl_path = os.path.join(os.path.dirname(__file__), 'TTL') |
18 |
| - self.graph = Graph() |
19 | 21 |
|
20 |
| - #load bald graphs from cdl |
21 |
| - for cdl_file in glob.glob(os.path.join(os.path.dirname(__file__), 'CDL', '*.cdl')): |
22 |
| - with self.temp_filename('.nc') as tfile: |
23 |
| - subprocess.check_call(['ncgen', '-o', tfile, cdl_file]) |
24 |
| - root_container = bald.load_netcdf(tfile, cache=self.acache) |
25 |
| - curr_g = root_container.rdfgraph() |
26 |
| - |
27 |
| - #merge into graph in test obj |
28 |
| - self.graph = self.graph + curr_g |
| 22 | + # Check to see if another test has already loaded the graph. |
| 23 | + if not loaded_boolean: |
| 24 | + # load bald graphs from cdl |
| 25 | + for cdl_file in glob.glob(os.path.join(self.cdl_path, '*.cdl')): |
| 26 | + with self.temp_filename('.nc') as tfile: |
| 27 | + subprocess.check_call(['ncgen', '-o', tfile, cdl_file]) |
| 28 | + root_container = bald.load_netcdf(tfile, cache=self.acache) |
| 29 | + curr_g = root_container.rdfgraph() |
| 30 | + |
| 31 | + #merge into graph in test obj |
| 32 | + thisGraph[0] = thisGraph[0] + curr_g |
| 33 | + print('setting loaded_boolean') |
| 34 | + loaded_boolean.append(True) |
| 35 | + self.graph = thisGraph[0] |
29 | 36 |
|
30 | 37 | def test_sparql_count_standard_names(self):
|
31 | 38 | #query standard_name values used and frequency
|
|
0 commit comments