From bad810a544077e4b486b055ca7954d8229f8829c Mon Sep 17 00:00:00 2001 From: fernandocrz Date: Mon, 30 Oct 2023 17:23:05 -0300 Subject: [PATCH] add test related to magic commands --- pipreqs/pipreqs.py | 2 - tests/_data_notebook/magic_commands.ipynb | 65 +++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 tests/_data_notebook/magic_commands.ipynb diff --git a/pipreqs/pipreqs.py b/pipreqs/pipreqs.py index efccefc..fc1ab81 100644 --- a/pipreqs/pipreqs.py +++ b/pipreqs/pipreqs.py @@ -157,8 +157,6 @@ def get_all_imports(path, encoding="utf-8", extra_ignore_dirs=None, follow_links continue else: logging.error("Failed on file: %s" % file_name) - if filter_ext(file_name, [".ipynb"]) and PythonExporter and not ignore_notebooks: - logging.error("Magic command without % might be failed") raise exc # Clean up imports diff --git a/tests/_data_notebook/magic_commands.ipynb b/tests/_data_notebook/magic_commands.ipynb new file mode 100644 index 0000000..23dc2d2 --- /dev/null +++ b/tests/_data_notebook/magic_commands.ipynb @@ -0,0 +1,65 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Magic test" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%automagic true" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ls -la\n", + "logstate" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ls -la" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%automagic false" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ls -la" + ] + } + ], + "metadata": { + "language_info": { + "name": "python" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +}