File tree Expand file tree Collapse file tree 3 files changed +41
-12
lines changed
Expand file tree Collapse file tree 3 files changed +41
-12
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,44 @@ cmp cli_test.ipynb tests/fixtures/_gold.ipynb
3131rm cli_test.ipynb
3232
3333
34+ # ##############################################################################
35+ # Recursive with a regexp, to stdout.
36+ # ##############################################################################
37+
38+ nbmerge \
39+ --recursive -i \
40+ -p " (1_Intro|2_Middle|3_Conclusion)\.ipynb" \
41+ > cli_test.ipynb
42+
43+ cmp cli_test.ipynb tests/fixtures/_gold.ipynb
44+
45+ # ##############################################################################
46+ # Recursive with a regexp, explicit output.
47+ # ##############################################################################
48+
49+ nbmerge \
50+ --recursive -i \
51+ -p " (1_Intro|2_Middle|3_Conclusion)\.ipynb" \
52+ -o cli_test.ipynb
53+
54+ cmp cli_test.ipynb tests/fixtures/_gold.ipynb
55+
56+ rm cli_test.ipynb
57+
58+ # ##############################################################################
59+ # Recursive with a regexp and explict input, explicit output.
60+ # ##############################################################################
61+
62+ nbmerge \
63+ --recursive -i \
64+ -p " (2_Middle|3_Conclusion)\.ipynb" \
65+ -o cli_test.ipynb \
66+ tests/fixtures/1_Intro.ipynb
67+
68+ cmp cli_test.ipynb tests/fixtures/_gold.ipynb
69+
70+ rm cli_test.ipynb
71+
3472# ##############################################################################
3573# When called without any arguments, nbmerge should emit a usage message.
3674# ##############################################################################
Original file line number Diff line number Diff line change @@ -136,7 +136,6 @@ def parse_plan(args=None, base_dir=None):
136136 parser = argparse .ArgumentParser (prog = "nbmerge" ,
137137 description = __description__ )
138138
139-
140139 parser .add_argument ("-o" , "--output" ,
141140 help = "Write to the specified file" )
142141
@@ -164,13 +163,6 @@ def parse_plan(args=None, base_dir=None):
164163 args = parser .parse_args (args )
165164
166165 file_paths = args .files [:]
167- # Didn't notice this until trying a pattern I don't use as much from the
168- # command line. The execution name is being collected as part of the
169- # filepaths. I don't know why. Perhaps something to do with using
170- # it as an entry point?
171- # XXX: TODO: KLUDGE
172- if file_paths and file_paths [0 ].endswith ("nbmerge" ):
173- file_paths = file_paths [1 :]
174166
175167 if not file_paths and not args .recursive :
176168 parser .print_help ()
@@ -194,7 +186,7 @@ def parse_plan(args=None, base_dir=None):
194186
195187
196188def main (args = None ):
197- plan = parse_plan (args or sys . argv )
189+ plan = parse_plan (args )
198190
199191 nb = merge_notebooks (plan ['base_dir' ],
200192 plan ['notebooks' ],
Original file line number Diff line number Diff line change 11import os
2- import subprocess
32import sys
43import unittest
54
@@ -61,7 +60,7 @@ def test_parse_plan(self):
6160 self .assertTrue (plan ["verbose" ])
6261 self .assertEqual (plan ["output_file" ], "myfile.ipynb" )
6362 with self .assertRaises (IOError ):
64- parse_plan (["nbmerge" , " this-file-doesn't-exist" ])
63+ parse_plan (["this-file-doesn't-exist" ])
6564
6665 def test_annotate_source_path (self ):
6766 nb_path = os .path .join (FIXTURES_DIR , "1_Intro.ipynb" )
@@ -72,7 +71,7 @@ def test_annotate_source_path(self):
7271 os .path .join ('fixtures' , '1_Intro.ipynb' ))
7372
7473 def test_main_to_stdout (self ):
75- main ([ 'nbmerge' ] + TARGET_NBS )
74+ main (TARGET_NBS )
7675 self ._validate_merged_three (reads (sys .stdout .getvalue (), as_version = 4 ))
7776
7877 def test_main_to_file (self ):
You can’t perform that action at this time.
0 commit comments