Skip to content

Commit

Permalink
Test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhJae committed Aug 25, 2023
1 parent af8858d commit 3c637a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install mobiledoc module
run: |
pip install -e .
- name: Run tests
run: |
cd test
Expand Down
19 changes: 14 additions & 5 deletions test/test_mobiledoc.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
from pathlib import Path
import unittest
import os
import sys
import subprocess
import json


class TestMobiledocGeneratedFiles(unittest.TestCase):

def setUp(self):
self.testdata_python_dir = "testdata/python"
self.testdata_json_dir = "testdata/Json"

def execute_and_check_py_file(self, test_type, idx):
"""Helper method to execute a given Python file."""
py_file_path = f"{self.testdata_python_dir}/{test_type}/test_{test_type}_{idx}.py"
result = subprocess.run(['python3', py_file_path], capture_output=True, text=True)
def execute_and_check_py_file(self, test_type, test_num):
py_file_path = f"testdata/python/{test_type}/test_{test_type}_{test_num}.py"

# Update sys.path to include the directory containing mobiledoc
sys.path.append(str(Path(py_file_path).parent.parent.parent)) # Adjusting path to repository root

result = subprocess.run([sys.executable, py_file_path], capture_output=True, text=True)

# Remove the path adjustment (cleanup)
sys.path.remove(str(Path(py_file_path).parent.parent.parent))

self.assertEqual(result.returncode, 0, msg=f"Error executing: {py_file_path}\n{result.stderr}")

def deserialize_and_check_json_file(self, test_type, idx):
Expand Down

0 comments on commit 3c637a1

Please sign in to comment.