Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/matrix-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
run: |
pip install -e .[all]
- name: Run tests
run: cd tests && python run.py prod
run: python run_tests.py prod
11 changes: 5 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ jobs:

- name: Run tests
run: |
cd tests
coverage run --parallel-mode run.py prod
DEVELOPMENT=1 coverage run --parallel-mode test_web_api.py
coverage run --parallel-mode run_tests.py prod
DEVELOPMENT=1 coverage run --parallel-mode -m tests.test_web_api
coverage combine
coverage xml

- run: cd tests && coverage report
- run: coverage report

- name: Make sure pre-commit hooks pass
uses: pre-commit/action@v3.0.1
Expand Down Expand Up @@ -109,7 +108,7 @@ jobs:
pip install -e .[all]

- name: Run tests on Windows
run: cd tests && python run.py prod
run: python run_tests.py prod

- name: Make sure the CLI outputs utf8 on Windows
# Note: we're checking something CLI specific, from a prompt, so we don't want to run
Expand Down Expand Up @@ -156,4 +155,4 @@ jobs:
run: pip install httpx

- name: unit test the web API
run: python tests/test_web_api.py
run: python -m tests.test_web_api
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,35 @@ To install the latest published version on PyPI:

pip install readalongs

To install the current development version, clone the repo and pip install it
locally:
To install the current development version, clone the repo and pip
install it locally, either with [hatch](https://hatch.pypa.io) (this
will open a new shell with the package installed inside it):

```sh
$ git clone https://github.com/ReadAlongs/Studio.git
$ cd Studio
$ pip install -e .
```
git clone https://github.com/ReadAlongs/Studio.git
cd Studio
hatch shell

or directly with `pip` (you should be using a [virtual
environment](https://docs.python.org/3/library/venv.html) though!):

git clone https://github.com/ReadAlongs/Studio.git
cd Studio
pip install -e .

### Verifying your installation

Run `readalongs -h` to confirm that installation was successful.

If you installed the current development version with Git, you can also run the
full test suite (requires installing the dev dependencies):
full test suite, either with `hatch`:

hatch test

or test the installed version (requires installing dev dependencies):

pip install 'readalongs[dev]' # if you installed from PyPI, or
pip install -e '.[dev]' # if you installed from a local clone
python tests/run.py dev
python run_tests.py dev

And you can download our [open samples on GitHub](https://github.com/ReadAlongs/OpenSamples)
to run your first alignments.
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ include = [
[tool.hatch.env]
requires = [ "hatch-pip-compile" ]

[tool.hatch.envs.hatch-test]
features = [ "dev" ]

[tool.hatch.envs.prod]
features = [ "heroku" ]
type = "pip-compile"
Expand Down
39 changes: 19 additions & 20 deletions tests/run.py → run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@
import sys
from unittest import TestLoader, TestSuite, TextTestRunner

from test_align_cli import TestAlignCli
from test_anchors import TestAnchors
from test_api import TestAlignApi
from test_audio import TestAudio
from test_config import TestConfig
from test_dna_text import TestDNAText
from test_dna_utils import TestDNAUtils
from test_dtd import TestDTD
from test_force_align import TestForceAlignment, TestXHTML
from test_g2p_cli import TestG2pCli
from test_make_xml_cli import TestMakeXMLCli
from test_misc import TestMisc
from test_package_urls import TestPackageURLs
from test_silence import TestSilence
from test_smil import TestSmilUtilities
from test_temp_file import TestTempFile
from test_tokenize_cli import TestTokenizeCli
from test_tokenize_xml import TestTokenizer
from test_web_api import TestWebApi

from readalongs.log import LOGGER
from tests.test_align_cli import TestAlignCli
from tests.test_anchors import TestAnchors
from tests.test_api import TestAlignApi
from tests.test_audio import TestAudio
from tests.test_config import TestConfig
from tests.test_dna_text import TestDNAText
from tests.test_dna_utils import TestDNAUtils
from tests.test_dtd import TestDTD
from tests.test_force_align import TestForceAlignment, TestXHTML
from tests.test_g2p_cli import TestG2pCli
from tests.test_make_xml_cli import TestMakeXMLCli
from tests.test_misc import TestMisc
from tests.test_package_urls import TestPackageURLs
from tests.test_silence import TestSilence
from tests.test_smil import TestSmilUtilities
from tests.test_temp_file import TestTempFile
from tests.test_tokenize_cli import TestTokenizeCli
from tests.test_tokenize_xml import TestTokenizer
from tests.test_web_api import TestWebApi

LOADER = TestLoader()

Expand Down
9 changes: 6 additions & 3 deletions tests/test_align_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
from pathlib import Path
from unittest import main

from basic_test_case import BasicTestCase
from lxml.html import fromstring
from sound_swallower_stub import SoundSwallowerStub

from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.cli import align, langs

from .basic_test_case import BasicTestCase
from .sound_swallower_stub import SoundSwallowerStub


def write_file(filename: str, file_contents: str) -> str:
"""Write file_contents to file filename, and return its name (filename)"""
Expand Down Expand Up @@ -617,7 +618,9 @@ def slurp_text(filename, encoding):
with open(filename, "r", encoding=encoding) as f:
return f.read()

base_file = write_file(self.tempdir / "add-bom-input.txt", "Random Text été")
base_file = write_file(
str(self.tempdir / "add-bom-input.txt"), "Random Text été"
)
bom_file = self.add_bom(base_file)
self.assertEqual(
slurp_text(base_file, "utf-8"), slurp_text(bom_file, "utf-8-sig")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_anchors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from io import StringIO
from unittest import main

from basic_test_case import BasicTestCase, silence_c_stderr

from readalongs.align import align_audio
from readalongs.log import LOGGER

from .basic_test_case import BasicTestCase, silence_c_stderr


class TestAnchors(BasicTestCase):
"""Unit testing for the anchors functionality in readalongs align"""
Expand Down
5 changes: 3 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
from unittest import main

import click
from basic_test_case import BasicTestCase, silence_logs
from sound_swallower_stub import SoundSwallowerStub

from readalongs import api
from readalongs.log import LOGGER

from .basic_test_case import BasicTestCase, silence_logs
from .sound_swallower_stub import SoundSwallowerStub


class TestAlignApi(BasicTestCase):
"""Test suite for the API way to call align()"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from subprocess import run
from unittest import main

from basic_test_case import BasicTestCase

from readalongs.audio_utils import (
extract_section,
join_section,
Expand All @@ -19,6 +17,8 @@
)
from readalongs.log import LOGGER

from .basic_test_case import BasicTestCase


class TestAudio(BasicTestCase):
"""Test suite for various audio contents handling methods"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_dna_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
from io import StringIO
from unittest import main

from basic_test_case import BasicTestCase
from lxml import etree

from readalongs.text import tokenize_xml
from readalongs.text.add_ids_to_xml import add_ids
from readalongs.text.util import parse_xml

from .basic_test_case import BasicTestCase


class TestDNAText(BasicTestCase):
"""Test handling of DNA text in tokenization"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_force_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from io import StringIO
from tempfile import TemporaryDirectory

from basic_test_case import BasicTestCase, silence_c_stderr
from lxml import etree
from soundswallower import get_model_path

Expand All @@ -26,6 +25,8 @@
from readalongs.portable_tempfile import PortableNamedTemporaryFile
from readalongs.text.util import load_txt, load_xml, save_xml

from .basic_test_case import BasicTestCase, silence_c_stderr


class TestForceAlignment(BasicTestCase):
"""Unit testing suite for forced-alignment with SoundSwallower"""
Expand Down
7 changes: 4 additions & 3 deletions tests/test_g2p_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@
from io import StringIO
from unittest import main

from basic_test_case import BasicTestCase
from lxml import etree
from sound_swallower_stub import SoundSwallowerStub
from test_make_xml_cli import updateFormatVersion, updateStudioVersion

from readalongs.align import align_audio
from readalongs.cli import align, g2p, make_xml, tokenize
from readalongs.log import LOGGER
from readalongs.text.convert_xml import convert_xml
from readalongs.text.util import parse_xml

from .basic_test_case import BasicTestCase
from .sound_swallower_stub import SoundSwallowerStub
from .test_make_xml_cli import updateFormatVersion, updateStudioVersion


def run_convert_xml(input_string):
"""wrap convert_xml to make unit testing easier"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_make_xml_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from shutil import copyfile
from unittest import main

from basic_test_case import BasicTestCase

# from readalongs.log import LOGGER
from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.align_utils import create_input_ras, create_ras_from_text
from readalongs.cli import align, make_xml

from .basic_test_case import BasicTestCase


def updateFormatVersion(input):
return input.replace("{{format_version}}", READALONG_FILE_FORMAT_VERSION)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from unittest import main

import click
from basic_test_case import BasicTestCase
from lxml import etree
from pep440 import is_canonical
from test_dna_utils import segments_from_pairs

from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.align import split_silences
Expand All @@ -29,6 +27,9 @@
)
from readalongs.util import JoinerCallbackForClick

from .basic_test_case import BasicTestCase
from .test_dna_utils import segments_from_pairs


class TestMisc(BasicTestCase):
"""Testing miscellaneous stuff"""
Expand Down
3 changes: 2 additions & 1 deletion tests/test_package_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
from unittest import main

import requests
from basic_test_case import BasicTestCase, silence_logs

from readalongs.text.make_package import (
FONTS_BUNDLE_URL,
JS_BUNDLE_URL,
fetch_bundle_file,
)

from .basic_test_case import BasicTestCase, silence_logs


class TestPackageURLs(BasicTestCase):
def test_urls(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_silence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import os
from unittest import main

from basic_test_case import BasicTestCase
from pydub import AudioSegment

from readalongs.cli import align
from readalongs.text.util import load_xml

from .basic_test_case import BasicTestCase


class TestSilence(BasicTestCase):
"""Test suite for inserting silences into a readalong"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_smil.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from textwrap import dedent
from unittest import main

from basic_test_case import BasicTestCase

from readalongs.text.make_smil import make_smil, parse_smil

from .basic_test_case import BasicTestCase


class TestSmilUtilities(BasicTestCase):
"""Unit test suite for the smil writing and parsing utilities"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_tokenize_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import os
from unittest import main

from basic_test_case import BasicTestCase

from readalongs.cli import make_xml, tokenize

from .basic_test_case import BasicTestCase

# from readalongs.log import LOGGER


Expand Down
4 changes: 2 additions & 2 deletions tests/test_web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from unittest import main
from unittest.mock import patch

from basic_test_case import BasicTestCase

from readalongs._version import READALONG_FILE_FORMAT_VERSION, VERSION
from readalongs.log import LOGGER
from readalongs.text.add_ids_to_xml import add_ids
Expand All @@ -21,6 +19,8 @@
from readalongs.util import get_langs
from readalongs.web_api import OutputFormat, create_grammar, web_api_app

from .basic_test_case import BasicTestCase


class TestWebApi(BasicTestCase):
_API_CLIENT = None
Expand Down
Loading