Skip to content

Commit

Permalink
Use runpy instead of exec for script tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markcampanelli committed Feb 12, 2024
1 parent aa8492c commit 5beb491
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
Copyright 2023 Intelligent Measurement Systems LLC
"""

import importlib.resources
import os
import runpy


def test_getting_started():
def test_getting_started_script():
"""Test that getting started script runs without error."""
exec(
importlib.resources.files("pvfit.measurement.spectral_correction.demos")
.joinpath("getting_started.py")
.read_text()
)
runpy.run_path(os.path.abspath(__file__).replace("_test.py", ".py"))
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
Copyright 2023 Intelligent Measurement Systems LLC
"""

import importlib.resources
import os
import runpy


def test_getting_started_equation():
def test_getting_started_script():
"""Test that getting started script runs without error."""
exec(
importlib.resources.files("pvfit.modeling.dc.single_diode.equation.demos")
.joinpath("getting_started.py")
.read_text()
)
runpy.run_path(os.path.abspath(__file__).replace("_test.py", ".py"))
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
Copyright 2023 Intelligent Measurement Systems LLC
"""

import importlib.resources
import os
import runpy


def test_getting_started_model():
def test_getting_started_script():
"""Test that getting started script runs without error."""
exec(
importlib.resources.files("pvfit.modeling.dc.single_diode.model.demos")
.joinpath("getting_started.py")
.read_text()
)
runpy.run_path(os.path.abspath(__file__).replace("_test.py", ".py"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
PVfit testing: Using meteorological (MET) station data in single-diode model (SDM).
Copyright 2023 Intelligent Measurement Systems LLC
"""

import os
import runpy


def test_using_ghi_dni_dhi_ambient_temp_script():
"""Test that F and T_degC from MET data script runs without error."""
runpy.run_path(os.path.abspath(__file__).replace("_test.py", ".py"))

0 comments on commit 5beb491

Please sign in to comment.