Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel test #673

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHANGELOG.md merge=union
*.xlsx binary
*.min.js binary
*.min.css binary
doorstop/core/files/templates/html/output/*.js binary
doorstop/core/files/templates/html/output/**/*.js binary
doorstop/core/files/templates/html/tex-mml-chtml.js binary
doorstop/core/tests/files/published*.html binary

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ endif

RANDOM_SEED ?= $(shell date +%s)

PYTEST_OPTIONS := --doctest-modules
PYTEST_OPTIONS := --doctest-modules -n auto
ifndef DISABLE_COVERAGE
PYTEST_OPTIONS += --cov=$(PACKAGE) --cov-report=html --cov-report=term-missing
endif
Expand Down
1 change: 1 addition & 0 deletions doorstop/cli/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ def _get_tree(args, cwd, request_next_number=None, load=False):

"""
utilities.show("building tree...", flush=True)
log.debug(f"Building tree at {cwd}, project root {args.project}, request_next_number={request_next_number}")
tree = build(cwd=cwd, root=args.project, request_next_number=request_next_number)

if load:
Expand Down
1 change: 1 addition & 0 deletions doorstop/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def main(args=None): # pylint: disable=R0915
args = parser.parse_args(args=args)

# Configure logging
print(f"verbose: {args.verbose}")
utilities.configure_logging(args.verbose)

# Configure settings
Expand Down
24 changes: 13 additions & 11 deletions doorstop/cli/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import shutil
import tempfile
import unittest
from shutil import copytree
from unittest.mock import Mock, patch

from doorstop import common, settings
Expand Down Expand Up @@ -45,6 +46,7 @@ class MockTestCase(TempTestCase):

def setUp(self):
super().setUp()
copytree(os.path.join("reqs"), os.path.join(self.temp, "reqs"))
os.chdir(self.temp)
common.touch(".mockvcs")
_clear_tree()
Expand Down Expand Up @@ -133,7 +135,7 @@ def get_next_number():
@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.SERVER_HOST", None)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestAdd(unittest.TestCase):
class TestAdd(MockTestCase):
"""Integration tests for the 'doorstop add' command."""

@classmethod
Expand Down Expand Up @@ -183,7 +185,7 @@ def test_add_error(self):

@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestAddServer(unittest.TestCase):
class TestAddServer(MockTestCase):
"""Integration tests for the 'doorstop add' command using a server."""

@classmethod
Expand Down Expand Up @@ -221,7 +223,7 @@ def test_add_force(self):

@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestRemove(unittest.TestCase):
class TestRemove(MockTestCase):
"""Integration tests for the 'doorstop remove' command."""

ITEM = os.path.join(TUTORIAL, "TUT003.yml")
Expand All @@ -244,7 +246,7 @@ def test_remove_error(self):

@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestReorder(unittest.TestCase):
class TestReorder(MockTestCase):
"""Integration tests for the 'doorstop reorder' command."""

@classmethod
Expand Down Expand Up @@ -322,7 +324,7 @@ def test_reorder_with_backslashes_in_text(self):
@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.SERVER_HOST", None)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestEdit(unittest.TestCase):
class TestEdit(MockTestCase):
"""Integration tests for the 'doorstop edit' command."""

@patch("subprocess.call", Mock())
Expand Down Expand Up @@ -376,7 +378,7 @@ def test_edit_error(self):

@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestLink(unittest.TestCase):
class TestLink(MockTestCase):
"""Integration tests for the 'doorstop link' command."""

ITEM = os.path.join(TUTORIAL, "TUT003.yml")
Expand Down Expand Up @@ -404,7 +406,7 @@ def test_link_unknown_parent(self):

@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestUnlink(unittest.TestCase):
class TestUnlink(MockTestCase):
"""Integration tests for the 'doorstop unlink' command."""

ITEM = os.path.join(TUTORIAL, "TUT003.yml")
Expand Down Expand Up @@ -433,7 +435,7 @@ def test_unlink_unknown_parent(self):


@unittest.skipUnless(os.getenv(ENV), REASON)
class TestClear(unittest.TestCase):
class TestClear(MockTestCase):
"""Integration tests for the 'doorstop clear' command."""

@patch("doorstop.core.item.Item.clear")
Expand Down Expand Up @@ -482,7 +484,7 @@ def test_clear_error(self):


@unittest.skipUnless(os.getenv(ENV), REASON)
class TestReview(unittest.TestCase):
class TestReview(MockTestCase):
"""Integration tests for the 'doorstop review' command."""

@patch("doorstop.core.item.Item.review")
Expand Down Expand Up @@ -527,7 +529,7 @@ def test_review_error(self):
@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.SERVER_HOST", None)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestImport(unittest.TestCase):
class TestImport(MockTestCase):
"""Integration tests for the 'doorstop import' command."""

def tearDown(self):
Expand Down Expand Up @@ -646,7 +648,7 @@ def test_import_xlsx_to_document_existing(self):

@unittest.skipUnless(os.getenv(ENV), REASON)
@patch("doorstop.settings.ADDREMOVE_FILES", False)
class TestImportServer(unittest.TestCase):
class TestImportServer(MockTestCase):
"""Integration tests for the 'doorstop import' command using a server."""

def tearDown(self):
Expand Down
3 changes: 2 additions & 1 deletion doorstop/core/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ def new(
:return: new :class:`~doorstop.core.document.Document`

"""
log.debug(f"Adding document: prefix={prefix}, digits={digits}, seperator={sep}, auto={auto}, root={root}, tree={tree}, path={path}")
# Check separator
if sep and sep not in settings.SEP_CHARS:
raise DoorstopError("invalid UID separator '{}'".format(sep))

config = os.path.join(path, Document.CONFIG)

log.debug(f"Checking for document {config}")
# Check for an existing document
if os.path.exists(config):
raise DoorstopError("document already exists: {}".format(path))
Expand Down
6 changes: 4 additions & 2 deletions doorstop/core/publishers/tests/test_publisher_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def test_publish_document(self, mock_open, mock_makedirs):
path2 = publisher.publish(self.document, path)
# Assert
self.assertIs(path, path2)
mock_makedirs.assert_called_once_with(self.dirpath)
mock_open.assert_called_once_with(path, "wb")
mock_makedirs.assert_called_with(os.sep.join([self.dirpath, "documents"]))
mock_open.assert_called_once_with(
os.sep.join([os.path.dirname(path), "documents", "published.html"]), "wb"
)

@patch("os.path.isdir", Mock(return_value=False))
@patch("os.makedirs")
Expand Down
1 change: 1 addition & 0 deletions doorstop/core/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def _place(self, document):

"""
log.debug("trying to add {}...".format(document))
print(f"_place: {self.document}")
if not self.document: # tree is empty
if document.parent:
msg = "unknown parent for {}: {}".format(document, document.parent)
Expand Down
Loading
Loading