Change loader to return serializable objects#150
Conversation
Now that it is possible for tests to run in parallel it require serialize and deserialize the test to another process. For this to work the test must be serializable. Most of the time it works fine but sometimes (for example when tests are used with decorator) it will not work. Change loader to return a serializable test. The returned object will hold a metadata about the test (file, and symbol). Each processes will use this information to load the test on spot and run it.
RLTest/loader.py
Outdated
| self.name = '{}:{}'.format(self.modulename, symbol) | ||
|
|
||
| def initialize(self): | ||
| module_file = open(self.filename, 'r') |
There was a problem hiding this comment.
default open is read, can drop the 'r'
| return self.target.__name__ | ||
|
|
||
| class TestMethod(object): | ||
| is_class = False |
There was a problem hiding this comment.
Shouldn't this be in caps since it's used? At this level IS_CLASS = False
There was a problem hiding this comment.
Kept it the same as it is on TestClass and TestFunction, other parts in the code seems to use it so I did not want to change it.
RLTest/loader.py
Outdated
| self.name = '{}:{}'.format(self.modulename, symbol) | ||
|
|
||
| def initialize(self): | ||
| module_file = open(self.filename, 'r') |
There was a problem hiding this comment.
Dame default open comment:
module_file = open(self.filename)
chayim
left a comment
There was a problem hiding this comment.
It looks like TestFunction and TestClass are (almost) identical. Maybe they should both inherit from an abc.ABC and just implement different constructors?
Codecov Report
@@ Coverage Diff @@
## master #150 +/- ##
==========================================
- Coverage 36.98% 36.57% -0.42%
==========================================
Files 17 17
Lines 2136 2160 +24
==========================================
Hits 790 790
- Misses 1346 1370 +24
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Those were different before and I wanted to keep changes to be as small as possible because the test are not covering enough to feel safe with big changes. I agree we should do a bigger refactoring and improve testing. |
Now that it is possible for tests to run in parallel it require serialize and deserialize the test to another process. For this to work the test must be serializable. Most of the time it works fine but sometimes (for example when tests are used with decorator) it will not work.
Change loader to return a serializable test. The returned object will hold a metadata about the test (file, and symbol). Each processes will use this information to load the test on spot and run it.