Skip to content

Change loader to return serializable objects#150

Merged
MeirShpilraien merged 4 commits intomasterfrom
serializabled_tests
Jan 12, 2022
Merged

Change loader to return serializable objects#150
MeirShpilraien merged 4 commits intomasterfrom
serializabled_tests

Conversation

@MeirShpilraien
Copy link

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.

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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default open is read, can drop the 'r'

return self.target.__name__

class TestMethod(object):
is_class = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be in caps since it's used? At this level IS_CLASS = False

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dame default open comment:

module_file = open(self.filename)

Copy link
Contributor

@chayim chayim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like TestFunction and TestClass are (almost) identical. Maybe they should both inherit from an abc.ABC and just implement different constructors?

@codecov-commenter
Copy link

Codecov Report

Merging #150 (c45e34d) into master (8235999) will decrease coverage by 0.41%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 36.57% <0.00%> (-0.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
RLTest/__main__.py 0.00% <0.00%> (ø)
RLTest/loader.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8235999...c45e34d. Read the comment docs.

@MeirShpilraien
Copy link
Author

It looks like TestFunction and TestClass are (almost) identical. Maybe they should both inherit from an abc.ABC and just implement different constructors?

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.

@MeirShpilraien MeirShpilraien merged commit 0794884 into master Jan 12, 2022
@MeirShpilraien MeirShpilraien deleted the serializabled_tests branch January 12, 2022 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants