-
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.
chore: copy
%%bigquery
magics tests from google-cloud-bigquery (#8)
* chore: copy magics unit tests from google-cloud-bigquery * update tests to use bigquery_magics module * remove auth from unit tests * fix coverage
- Loading branch information
Showing
12 changed files
with
525 additions
and
6 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 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,13 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
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,21 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
def strip_region_tags(sample_text: str) -> str: | ||
"""Remove blank lines and region tags from sample text""" | ||
magic_lines = [ | ||
line for line in sample_text.split("\n") if len(line) > 0 and "# [" not in line | ||
] | ||
return "\n".join(magic_lines) |
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,44 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import typing | ||
from typing import Iterator | ||
|
||
import pytest | ||
|
||
if typing.TYPE_CHECKING: | ||
from IPython.core.interactiveshell import TerminalInteractiveShell | ||
|
||
interactiveshell = pytest.importorskip("IPython.terminal.interactiveshell") | ||
tools = pytest.importorskip("IPython.testing.tools") | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def ipython() -> "TerminalInteractiveShell": | ||
config = tools.default_config() | ||
config.TerminalInteractiveShell.simple_prompt = True | ||
shell = interactiveshell.TerminalInteractiveShell.instance(config=config) | ||
return shell | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def ipython_interactive( | ||
ipython: "TerminalInteractiveShell", | ||
) -> Iterator["TerminalInteractiveShell"]: | ||
"""Activate IPython's builtin hooks | ||
for the duration of the test scope. | ||
""" | ||
with ipython.builtin_trap: | ||
yield ipython |
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,8 @@ | ||
[mypy] | ||
; We require type annotations in all samples. | ||
strict = True | ||
exclude = noxfile\.py | ||
warn_unused_configs = True | ||
|
||
[mypy-IPython.*,nox,noxfile_config,pandas] | ||
ignore_missing_imports = True |
Oops, something went wrong.