Skip to content

ability switch evaluated code environment to module #241

Open

Description

@machow

Currently, pythonwhat uses subprocesses for evaluated student / solution. For cases where a main script imports a custom module that is part of an exercise, it would be useful to set the module as the "environment". For example, in the code below we may want to check config, even if __main__.py is the script executed by the process.

__main__.py:

from app import app

app.py:

from somelibrary import load_config, Service

config = load_config(...)

app = Service(config)

SCT sketch

(Ex()
     .check_file('app.py')
     .set_module_env('app')     # exposes variables in module "app"
     .test_object('config')
     )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions