-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54fa918
commit 40c966e
Showing
11 changed files
with
260 additions
and
869 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
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
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
Empty file.
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,122 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "39c26caf-db01-40d7-b62b-4973537b7b9c", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [ | ||
"clear-outputs" | ||
] | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"99.95" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# clear outputs\n", | ||
"book_price = 99.95\n", | ||
"num_students = 55\n", | ||
"book_price" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ff62f5c5-3ad9-454c-ac42-7bd955e7c8d6", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [ | ||
"term-directive" | ||
] | ||
}, | ||
"source": [ | ||
"{term}`glossary term` should contain a link." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e41339fc-9bff-4560-b682-9169405f8199", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [ | ||
"hide-cell" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"print(\"This cell should be hidden\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "53658e40-ffe4-4c73-9368-374d8cf54abb", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [ | ||
"remove-cell" | ||
] | ||
}, | ||
"outputs": [ | ||
{ | ||
"ename": "AssertionError", | ||
"evalue": "This cell should have been removed.", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[3], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#This cell should be removed.\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mThis cell should have been removed.\u001b[39m\u001b[38;5;124m'\u001b[39m\n", | ||
"\u001b[0;31mAssertionError\u001b[0m: This cell should have been removed." | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#This cell should be removed.\n", | ||
"assert False, 'This cell should have been removed.'" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python Camp", | ||
"language": "python", | ||
"name": "env" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,26 @@ | ||
from course_utils.postprocessing import Notebook | ||
import unittest | ||
import json | ||
|
||
class TestPostProcessing(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.notebook = Notebook('tests/test_postprocessing.ipynb') | ||
self.notebook.remove_tagged_cells() | ||
for cell in self.notebook: | ||
cell.make_glossary_links().apply_hidden().clear_outputs() | ||
self.notebook.hide_tags() | ||
|
||
def testProcessing(self): | ||
|
||
self.assertEqual(self.notebook.data[0]['outputs'], [], | ||
'cell output not cleared') | ||
self.assertRegex(self.notebook.data[1]['source'][0], r'\[.+\]\(https://gwu-libraries\.github.io/python-camp/glossary\.html#.+\)', | ||
'Markdown link missing or malformed') | ||
self.assertEqual(self.notebook.data[2]['source'][0], '#Click to see the solution.\n', 'Hidden code cell missing initial comment.') | ||
self.assertEqual(self.notebook.data[2]['metadata']['jupyter'], | ||
{"source_hidden": True}, | ||
'source_hidden flag missing from hidden cell metadata') | ||
cells_for_removal = [cell for cell in self.notebook.data if 'remove-cell' in cell['metadata'].get('tags', [])] | ||
self.assertEqual(cells_for_removal, [], 'cells tagged for removal not removed') | ||
|
Oops, something went wrong.