Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve class methods from context-local variables #1

Open
grandrew opened this issue Aug 13, 2021 · 0 comments
Open

Resolve class methods from context-local variables #1

grandrew opened this issue Aug 13, 2021 · 0 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@grandrew
Copy link
Contributor

In this situation:

import pytest, gc
import ordered, random

__author__ = "Andrew Gree"
__copyright__ = "CriticalHop Inc."
__license__ = "MIT"


class MyVars:
    x: int
    steps: int
    def __init__(self) -> None:
        self.x = 0
        self.steps = 0

    def plus_x(self):
        self.x += 3
        self.count_steps()

    def minus_x(self):
        self.x -= 2
        self.count_steps()
    
    def count_steps(self):
        self.steps += 1

@pytest.mark.skip(reason="TODO")
def test_partial_context_oo_full():
    m = MyVars()
    m.x = 5
    with ordered.orderedcontext():
        # exit ordered context without exceptions with minimum steps
        while m.x != 12:  
            ordered.choice()()  
    assert m.x == 12
    assert m.steps == 4

we're calling choice() with no parameters. This code fails as no methods for m are generated.

A solution needed to have a logically expected behaviour:

  1. all variables explicitly used in the context are scanned for their class' methods
  2. if choice() is selecting all functions from heap then it's huge as Python always has a lot of stuff loaded. Maybe choice() must actually scan this module's globals() for functions and methods?
@grandrew grandrew added bug Something isn't working question Further information is requested labels Aug 13, 2021
@grandrew grandrew self-assigned this Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant