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

Fix reloader for modules run as scripts #1336

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Mar 26, 2021

  1. add tests for reloading module

    prepare test fixtures consisting of a package and module with relative & absolute import
    test scripting server runs with these variations
    - from package or from module
    - with or without reloader
    the server code is based off servertest.py
    lmmarsano committed Mar 26, 2021
    Configuration menu
    Copy the full SHA
    5bfcb4d View commit details
    Browse the repository at this point in the history
  2. pass reloader tests

    python doesn't have an obvious way to reveal the original command and module name, so we check the __main__ module for __package__ and infer it's a module running as a script unless the value is None, which implies a file path was provided
    modules running as scripts are invoked with -m flags
    packages running with scripts have base filename __main__.py
    from this we recreate an invocation
    lmmarsano committed Mar 26, 2021
    Configuration menu
    Copy the full SHA
    47a55ac View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2021

  1. test: prepare top-level & submodule for clarity

    these will support top-level module script test cases
    lmmarsano committed Mar 28, 2021
    Configuration menu
    Copy the full SHA
    80025ac View commit details
    Browse the repository at this point in the history
  2. test: add package main script and cases for top-level script

    arrange package script to import submodule
    new test cases check the top-level module name is prepared correctly
    module tests cases are renamed submodule for clarity
    lmmarsano committed Mar 28, 2021
    Configuration menu
    Copy the full SHA
    2fa900c View commit details
    Browse the repository at this point in the history
  3. pass new cases & refactor

    refactor function to return main script arguments
    lmmarsano committed Mar 28, 2021
    Configuration menu
    Copy the full SHA
    8013433 View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2021

  1. replace sys.modules access with import statement

    __main__ can be imported
    lmmarsano committed Apr 2, 2021
    Configuration menu
    Copy the full SHA
    abf3431 View commit details
    Browse the repository at this point in the history