Skip to content

Commit

Permalink
use with statements and specify encoding for open()
Browse files Browse the repository at this point in the history
  • Loading branch information
whoburg committed Jan 5, 2024
1 parent c7d78d0 commit 4c536ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gpkit/tests/test_repo.py
Expand Up @@ -37,8 +37,7 @@ def test_repo(repo=".", xmloutput=False):
skipsolvers = [s.strip() for s in settings["skipsolvers"].split(",")]

testpy = ("from gpkit.tests.from_paths import run;"
"run(xmloutput=%s, skipsolvers=%s)"
% (xmloutput, skipsolvers))
f"run(xmloutput={xmloutput}, skipsolvers={skipsolvers})")
subprocess.call(["python", "-c", testpy])
if repo != ".":
os.chdir("..")
Expand All @@ -64,7 +63,8 @@ def test_repos(repos=None, xmloutput=False, ingpkitmodels=False):
print("USING LOCAL DIRECTORY AS GPKITMODELS DIRECTORY")
repos_list_filename = "EXTERNALTESTS"
pip_install(".", local=True)
repos = [line.strip() for line in open(repos_list_filename, "r")]
with open(repos_list_filename, "r", encoding="UTF-8") as f:
repos = [line.strip() for line in f]
for repo in repos:
git_clone(repo)
test_repo(repo, xmloutput)
Expand All @@ -74,7 +74,7 @@ def get_settings():
"Gets settings from a TESTCONFIG file"
settings = defaultdict(str)
if os.path.isfile("TESTCONFIG"):
with open("TESTCONFIG", "r") as f:
with open("TESTCONFIG", "r", encoding="UTF-8") as f:
for line in f:
if len(line.strip().split(" : ")) > 1:
key, value = line.strip().split(" : ")
Expand All @@ -86,7 +86,7 @@ def git_clone(repo, branch="master"):
"Tries several times to clone a given repository"
cmd = ["git", "clone", "--depth", "1"]
cmd += ["-b", branch]
cmd += ["https://github.com/convexengineering/%s.git" % repo]
cmd += [f"https://github.com/convexengineering/{repo}.git"]
call_and_retry(cmd)


Expand Down

0 comments on commit 4c536ec

Please sign in to comment.