-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP for en#81 template macros and page filtering #152
WARNING: - 1 failing test in jupman_tools_test.py (test_zip_folder_test_chapter) - many failing tests in preamble_test.py related to gitignore #152: - initializing sphinx ignored files from gitignore using igittigitt - now supporting sphinx include_patterns - jupyter-example: added data/trial.json - created specs and mockups under _test/specs - zip_ignored holds now patterns relative to project root instead of zip root for uniformity - now building also stuff in _test/ by default - added jupman_tools _sphinx_filter and _sphinx_filter_cxt temporary functions - added jcxt.jpre_subroot param to JupmanContext (needed for proper ignoring when copying trees around) - created _test/integration_test.py for some gitignore test - build.py now handles case when no index is present (useful when debugging) deprecated: - chapter_patterns, trying to set it different from */ gives a warning new deps: - upgraded to Sphinx 5.1.1 from 4.5.0 (to support include_patterns) - Using igittigitt 2.1.2 to load .gitignore, since it doesn't support negated patterns: - challenge-example is no longer published (never liked it anyway) - READMEs in private dirs are no longer published (never liked them anyway) - for simplicity, requiring test deps also in main build (probably we will need them anyway)
- Loading branch information
1 parent
cbc3a0f
commit df72288
Showing
53 changed files
with
32,173 additions
and
6,899 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import sys | ||
sys.path.append('../') | ||
sys.path.append('.') # good lord, without this debugging in VSCode doesn't work | ||
|
||
#keep it first so we don't get deprecation warnings | ||
import jupman_tools as jmt | ||
|
||
from hypothesis import given | ||
from pprint import pprint | ||
from hypothesis.strategies import text | ||
from jupman_tools import ignore_spaces, tag_regex, JupmanConfig, SphinxConfig, JupmanContext, JupmanError, JupmanNotFoundError, FileKinds, JupmanPreprocessorError, JupmanEmptyChapterError, JupmanUnsupportedError | ||
import pytest | ||
import re | ||
from sphinx.application import Sphinx | ||
import os | ||
import nbformat | ||
import time | ||
import filecmp | ||
import shutil | ||
import nbsphinx | ||
import inspect | ||
from jupman_tools import debug | ||
from pprint import pformat | ||
|
||
from common_test import clean, make_jupman_context, make_sphinx_config, make_jcxt_gitignore_non_existing, make_jcxt_gitignored, make_jcxt_zip_ignored, make_jm, make_nb_resources, tconf | ||
import datetime | ||
|
||
class MockSphinx: | ||
def add_config_value(self, a,b,c): | ||
pass | ||
def add_transform(self, a): | ||
pass | ||
def add_javascript(self, a): | ||
pass | ||
def add_stylesheet(self, a): | ||
pass | ||
|
||
def test_setup(tconf): | ||
""" This test runs an entire build of jupman itself | ||
""" | ||
|
||
mockapp = MockSphinx() | ||
|
||
tconf.setup(mockapp) | ||
|
||
# so tests run smoothly also on non-jupman projects | ||
if os.path.exists('jupyter-example'): | ||
assert os.path.isfile(os.path.join(tconf.jm.generated, 'jupyter-example.zip')) | ||
if os.path.exists('python-example'): | ||
assert os.path.isfile(os.path.join(tconf.jm.generated, 'python-example.zip')) | ||
if os.path.exists('jup-and-py-example'): | ||
assert os.path.isfile(os.path.join(tconf.jm.generated, 'jup-and-py-example.zip')) | ||
if os.path.exists('challenge-example'): | ||
assert os.path.isfile(os.path.join(tconf.jm.generated, 'challenge-example.zip')) | ||
|
||
# test reproducible build zips https://github.com/DavidLeoni/jupman/issues/60 | ||
|
||
if os.path.exists('jup-and-py-example'): | ||
|
||
zpath1 = os.path.join(tconf.jm.generated, 'jup-and-py-example.zip') | ||
|
||
|
||
zpath2 = os.path.join(tconf.test_tmp, 'jup-and-py-example.zip') | ||
|
||
|
||
shutil.copyfile(zpath1, zpath2) | ||
time.sleep(2) | ||
tconf.setup(mockapp) | ||
|
||
assert filecmp.cmp(zpath1, zpath2, shallow=False) | ||
|
||
|
||
jcxtfs = [ make_jcxt_gitignore_non_existing, | ||
#make_jcxt_gitignored | ||
] | ||
@pytest.mark.parametrize("jcxtf", jcxtfs) | ||
def test_is_zip_ignored_after_exclude_init(jcxtf): | ||
""" WARNING: since some files we use here are gitignored, you may not have them on your system | ||
(or when a build is performed on github). Test should 'pass' anyway because | ||
when is_zip_ignored doesn't find an existing file, should return True anyway | ||
Maybe in the future we may recreate them automatically somehow | ||
@since 3.6 | ||
""" | ||
debug(f"Creating {jcxtf.__name__}") | ||
jcxt = jcxtf() | ||
|
||
cchal = "_test/chap1-complete/c-chal-sol.ipynb" | ||
dchal = "_test/chap1-complete/d_chal_sol.py" | ||
|
||
assert jmt.is_zip_ignored(jcxt, jcxt.jm.build) | ||
assert jmt.is_zip_ignored(jcxt, jcxt.jm.generated) | ||
assert jmt.is_zip_ignored(jcxt, '_private') | ||
assert jmt.is_zip_ignored(jcxt, cchal) | ||
assert jmt.is_zip_ignored(jcxt, dchal) | ||
|
||
assert jmt.is_zip_ignored(jcxt, '.git/index') | ||
assert jmt.is_zip_ignored(jcxt, '.git/') | ||
assert jmt.is_zip_ignored(jcxt, '.git/info/exclude') | ||
assert jmt.is_zip_ignored(jcxt, '.gitignore') | ||
assert jmt.is_zip_ignored(jcxt, '.gitattributes') | ||
|
||
# additional check in case you don't have the files on your system: | ||
|
||
assert jcxt.jm.build in jcxt.exclude_patterns | ||
assert jcxt.jm.generated in jcxt.exclude_patterns | ||
assert '_private' in jcxt.exclude_patterns | ||
assert "**-chal-sol.*" in jcxt.exclude_patterns | ||
assert "**-chal-sol.*" in jcxt.exclude_patterns | ||
|
||
assert '.git' in jcxt.exclude_patterns | ||
assert '.gitignore' in jcxt.exclude_patterns | ||
assert '.gitattributes' in jcxt.exclude_patterns |
Oops, something went wrong.