Coverage for src/robotide/namespace/variablefetcher.py: 42%

15 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 10:40 +0100

1# Copyright 2008-2015 Nokia Networks 

2# Copyright 2016- Robot Framework Foundation 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15 

16from .. import robotapi 

17 

18# NOTE! This is in own module to reduce the number of dependencies as this is executed in another process 

19 

20 

21def import_varfile(varfile_path, args): 

22 """ Seems that this function is never called """ 

23 temp = robotapi.RobotVariables() 

24 try: 

25 temp.set_from_file(varfile_path, args) 

26 except Exception as e: # DEBUG used to be SystemExit 

27 print(f"Failed to import variable file: {e}") 

28 raise robotapi.DataError('Variable file import failed') 

29 return [(name, _format_value(value), varfile_path) 

30 for (name, value) in temp.store.data.items()] 

31 

32 

33# Must be picklable 

34def _format_value(value): 

35 if isinstance(value, str): 35 ↛ 36line 35 didn't jump to line 36 because the condition on line 35 was never true1b

36 return value 

37 if isinstance(value, list): 37 ↛ 39line 37 didn't jump to line 39 because the condition on line 37 was always true1b

38 return u'[ %s ]' % u' | '.join(str(v) for v in value) 1b

39 return str(value)