cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
229
Views
1
Helpful
1
Replies

pyATS runtime.synchro.dict not updating nested list during Easypy run

Hi all,

I am working on a pyATS/Easypy test automation project where I maintain a shared dictionary across multiple test cases using runtime.synchro.dict.

Here is my setup:
# Initialize shared dictionary in main script
shared_dict = runtime.synchro.dict({
"DUT_IP": ["device1", "device2"],
"EXECUTION_FAILURE": False,
"DEVICE_NAME": [],
"TOTAL_PASSED": 0,
"TOTAL_FAILED": 0,
"TOTAL_TEST_CASES": 0,
"TOTALS": { "PASSED": 0, "FAILED": 0, "ERRORED": 0, "TOTAL": 0 },
"TEST_SUITES": {}, # dict of suite_name -> counters
"SUITES": [] # list of executed suites
})

Inside a test case, I try to append the suite name to the shared list:

 

self.parameters["shared_dict"]["SUITES"].append("test_suite_example")
log.warning(f"Current shared_dict: {self.parameters['shared_dict']}")

Expected behavior:

  • "test_suite_example" should appear in shared_dict["SUITES"].

Actual behavior:

  • shared_dict["SUITES"] remains empty ([]) even after append().

  • Other keys in shared_dict update correctly.

My questions:

  1. Is this a limitation of runtime.synchro.dict regarding nested objects like lists or dicts?

  2. What is the correct way to modify nested lists inside a runtime.synchro.dict during test execution?

  3. Should I switch to using a DB or a JSON dump to persist results across test cases, or can this be safely done in runtime.synchro.dict?

Environment:

  • pyATS 24.7

  • Python 3.10

  • Easypy job with multiple parallel test executions

Any guidance or best practices will be appreciated!

1 Accepted Solution

Accepted Solutions

I do not think yuou have a limitation here,  because self.parameters["shared_dict"]["SUITES"] is a proxy object that does not automatically synchronize with the underlying dict when you call a method like append. I think the workaround is to treat your nested mutable objects as immutable from the perspective of the synchro dict - get them, modify a copy, and reassign the result.

 
For your use case here, by using runtime.synchro.dict with the reassignment method is great, so i see no need to switch to a db or a json dump unless you have a requirement to persist the data beyond the single easypy job execution.
 
Hope this helps.
Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

View solution in original post

1 Reply 1

I do not think yuou have a limitation here,  because self.parameters["shared_dict"]["SUITES"] is a proxy object that does not automatically synchronize with the underlying dict when you call a method like append. I think the workaround is to treat your nested mutable objects as immutable from the perspective of the synchro dict - get them, modify a copy, and reassign the result.

 
For your use case here, by using runtime.synchro.dict with the reassignment method is great, so i see no need to switch to a db or a json dump unless you have a requirement to persist the data beyond the single easypy job execution.
 
Hope this helps.
Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io