PyUtilib / pyutilib

A collection of general Python utilities, including logging and file IO, subprocess management, plugin systems, and workflow management.
BSD 3-Clause "New" or "Revised" License
34 stars 20 forks source link

Improvements to import_file() and run_file() #70

Closed jsiirola closed 4 years ago

jsiirola commented 4 years ago

Fixes: N/A

Summary/Motivation:

This improves the robustness of import_file() and run_file() so that the sys.path is not left in an altered state in the event that the import raises an exception. This also switches to using tools from sys.path for performing path manipulations (instead of hard-coded / and \ characters).

Changes proposed in this PR:

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.
whart222 commented 4 years ago

@jsiirola Given the nature of these changes, I think it's important to add a few tests to confirm that these changes capture the behavior that motivated the PR.

jsiirola commented 4 years ago

@whart222: absolutely. Tests added.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.04%) to 62.046% when pulling d04eace1dafbfeaa5552a8782bdc6b8af285e1f8 on import-fixes into 12fddaf57468710c41da505c25d4cf855673bc3e on master.

ghackebeil commented 4 years ago

Was there a typo in the last test from this PR? It seems to be testing the wrong function.

On Dec 13, 2019, at 11:28 AM, Bethany Nicholson notifications@github.com wrote:

 Merged #70 into master.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

whart222 commented 4 years ago

@ghackebeil I'm not sure what you're referring to. Where do you think there's an error?