mirror of
https://github.com/aykhans/AzSuicideDataVisualization.git
synced 2025-07-01 14:07:48 +00:00
first commit
This commit is contained in:
39
.venv/Lib/site-packages/nbconvert/utils/tests/test_io.py
Normal file
39
.venv/Lib/site-packages/nbconvert/utils/tests/test_io.py
Normal file
@ -0,0 +1,39 @@
|
||||
"""Tests for utils.io"""
|
||||
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import io as stdlib_io
|
||||
import sys
|
||||
from io import StringIO
|
||||
|
||||
from ..io import unicode_std_stream
|
||||
|
||||
|
||||
def test_UnicodeStdStream():
|
||||
# Test wrapping a bytes-level stdout
|
||||
stdoutb = stdlib_io.BytesIO()
|
||||
stdout = stdlib_io.TextIOWrapper(stdoutb, encoding="ascii")
|
||||
|
||||
orig_stdout = sys.stdout
|
||||
sys.stdout = stdout
|
||||
try:
|
||||
sample = "@łe¶ŧ←"
|
||||
unicode_std_stream().write(sample)
|
||||
|
||||
output = stdoutb.getvalue().decode("utf-8")
|
||||
assert output == sample
|
||||
assert not stdout.closed
|
||||
finally:
|
||||
sys.stdout = orig_stdout
|
||||
|
||||
|
||||
def test_UnicodeStdStream_nowrap():
|
||||
# If we replace stdout with a StringIO, it shouldn't get wrapped.
|
||||
orig_stdout = sys.stdout
|
||||
sys.stdout = StringIO()
|
||||
try:
|
||||
assert unicode_std_stream() is sys.stdout
|
||||
assert not sys.stdout.closed
|
||||
finally:
|
||||
sys.stdout = orig_stdout
|
81
.venv/Lib/site-packages/nbconvert/utils/tests/test_pandoc.py
Normal file
81
.venv/Lib/site-packages/nbconvert/utils/tests/test_pandoc.py
Normal file
@ -0,0 +1,81 @@
|
||||
"""Test Pandoc module"""
|
||||
# -----------------------------------------------------------------------------
|
||||
# Copyright (C) 2014 The IPython Development Team
|
||||
#
|
||||
# Distributed under the terms of the BSD License. The full license is in
|
||||
# the file COPYING, distributed as part of this software.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Imports
|
||||
# -----------------------------------------------------------------------------
|
||||
import os
|
||||
import warnings
|
||||
|
||||
from nbconvert.tests.base import TestsBase
|
||||
|
||||
from ...tests.utils import onlyif_cmds_exist
|
||||
from .. import pandoc
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Classes and functions
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestPandoc(TestsBase):
|
||||
"""Collection of Pandoc tests"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.original_env = os.environ.copy()
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
pandoc.check_pandoc_version._cached = None
|
||||
|
||||
@onlyif_cmds_exist("pandoc")
|
||||
def test_pandoc_available(self):
|
||||
"""Test behaviour that pandoc functions raise PandocMissing as documented"""
|
||||
pandoc.clean_cache()
|
||||
|
||||
os.environ["PATH"] = ""
|
||||
with self.assertRaises(pandoc.PandocMissing):
|
||||
pandoc.get_pandoc_version()
|
||||
with self.assertRaises(pandoc.PandocMissing):
|
||||
pandoc.check_pandoc_version()
|
||||
with self.assertRaises(pandoc.PandocMissing):
|
||||
pandoc.pandoc("", "markdown", "html")
|
||||
|
||||
# original_env["PATH"] should contain pandoc
|
||||
os.environ["PATH"] = self.original_env["PATH"]
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
pandoc.get_pandoc_version()
|
||||
pandoc.check_pandoc_version()
|
||||
pandoc.pandoc("", "markdown", "html")
|
||||
self.assertEqual(w, [])
|
||||
|
||||
@onlyif_cmds_exist("pandoc")
|
||||
def test_minimal_version(self):
|
||||
original_minversion = pandoc._minimal_version
|
||||
|
||||
pandoc._minimal_version = "120.0"
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always")
|
||||
# call it twice to verify the cached value is used
|
||||
assert not pandoc.check_pandoc_version()
|
||||
assert not pandoc.check_pandoc_version()
|
||||
# only one warning after two calls, due to cache
|
||||
self.assertEqual(len(w), 1)
|
||||
# clear cache
|
||||
pandoc.check_pandoc_version._cached = None
|
||||
pandoc._minimal_version = pandoc.get_pandoc_version()
|
||||
assert pandoc.check_pandoc_version()
|
||||
|
||||
|
||||
def pandoc_function_raised_missing(f, *args, **kwargs):
|
||||
try:
|
||||
f(*args, **kwargs)
|
||||
except pandoc.PandocMissing:
|
||||
return True
|
||||
else:
|
||||
return False
|
@ -0,0 +1,13 @@
|
||||
from ..version import check_version
|
||||
|
||||
|
||||
def test_check_version():
|
||||
"""Test the behaviour of check_versionself.
|
||||
|
||||
This is mostly used to make sure the pandoc version is appropriate for the library.
|
||||
"""
|
||||
|
||||
assert check_version("1.19.2.4", "1.12.1")
|
||||
assert check_version("2.2.3.2", "1.12.1")
|
||||
assert check_version("1.19.2.4", "1.12.1", max_v="2.0")
|
||||
assert not check_version("2.2.3.2", "1.12.1", max_v="2.0")
|
Reference in New Issue
Block a user