Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ build_package() {
check_package() (
set -ex

# we don't have test_that tests yet.
Rscript -e 'devtools::test(reporter="check")'
R CMD check "$PKG_TARBALL" --as-cran
! grep -q 'WARNING' "$CHECK_LOG"
# .. because ': ' was resulting in an replacement by travis and an error
Expand All @@ -91,5 +89,5 @@ test_kernel() (
R CMD INSTALL "$PKG_TARBALL"
Rscript -e 'IRkernel::installspec()'
Rscript -e 'IRkernel::installspec(name = "testir", displayname = "testir")'
python -W ignore::DeprecationWarning test_ir.py
Rscript -e 'devtools::test()'
)
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Imports:
jsonlite (>= 0.9.6),
uuid,
digest
Remotes:
IRKernel/IRdisplay,
Remotes: IRKernel/IRdisplay,
Collate:
'logging.r'
'comm_manager.r'
Expand Down
2 changes: 2 additions & 0 deletions IRkernel.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
Expand Down
11 changes: 10 additions & 1 deletion test_ir.py → tests/testthat/test_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{}
options(jupyter.rich_display = TRUE)
'''
#this will not work!
#withr::with_options(list(jupyter.rich_display = FALSE), {})


Expand Down Expand Up @@ -63,6 +64,7 @@ def _execute_code(self, code, tests=True):
]

def test_display_vector(self):
"""display of vectors"""
code = '1:3'
reply, output_msgs = self._execute_code(code)

Expand All @@ -78,13 +80,15 @@ def test_display_vector(self):
self.assertIn('text/markdown', output_msgs[0]['content']['data'])

def test_display_vector_only_plaintext(self):
"""display of plain text vectors"""
code = without_rich_display.format('1:3')
reply, output_msgs = self._execute_code(code)
data = output_msgs[0]['content']['data']
self.assertEqual(len(data), 1, data.keys())
self.assertEqual(data['text/plain'], '[1] 1 2 3')

def test_irkernel_plots(self):
"""plotting"""
code = 'plot(1:3)'
reply, output_msgs = self._execute_code(code)

Expand All @@ -102,6 +106,7 @@ def test_irkernel_plots(self):
self.assertEqual(metadata['image/svg+xml']['isolated'], True)

def test_irkernel_plots_only_PNG(self):
"""plotting PNG"""
# the reset needs to happen in another execute because plots are sent after either
# the next plot is opened or everything is executed, not at the time when plot
# command is actually happening.
Expand All @@ -123,6 +128,7 @@ def test_irkernel_plots_only_PNG(self):
reply, output_msgs = self._execute_code(code, tests=False)

def test_irkernel_df_default_rich_output(self):
"""data.frame rich representation"""
code = 'data.frame(x = 1:3)'
reply, output_msgs = self._execute_code(code)

Expand All @@ -131,6 +137,7 @@ def test_irkernel_df_default_rich_output(self):
self.assertEqual(len(data), 3, data.keys())

def test_irkernel_df_no_rich_output(self):
"""data.frame plain representation"""
code = '''
options(jupyter.rich_display = FALSE)
data.frame(x = 1:3)
Expand All @@ -143,6 +150,7 @@ def test_irkernel_df_no_rich_output(self):
self.assertEqual(len(data), 1, data.keys())

def test_html_isolated(self):
"""HTML isolation"""
code = '''
repr_html.full_page <- function(obj) sprintf('<html><body>%s</body></html>', obj)
structure(0, class = 'full_page')
Expand All @@ -159,11 +167,12 @@ def test_html_isolated(self):
self.assertEqual(metadata['text/html']['isolated'], True)

def test_in_kernel_set(self):
"""jupyter.in_kernel option"""
reply, output_msgs = self._execute_code('getOption("jupyter.in_kernel")')
data = output_msgs[0]['content']['data']
self.assertGreaterEqual(len(data), 1, data.keys())
self.assertEqual(data['text/plain'], '[1] TRUE', data.keys())


if __name__ == '__main__':
unittest.main()
unittest.main(verbosity=2)
6 changes: 6 additions & 0 deletions tests/testthat/test_kernel.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
context('kernel')

status <- system2('python3', 'test_ir.py', wait=TRUE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be interesting what will happen if we submit that to CRAN: on my system, there is no python3 and in RStudio (or my r package install script), I don't have the kernel testing tool installed, so this tests will basically always fail.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we'll just remove this file from the tarball we submit to CRAN, in that case :-(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or use a series of system commands to install Anaconda ;-). But it may well block network access.

@flying-sheep flying-sheep Jul 5, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we add python3 and jupyter_kernel_test to SystemRequirements with an explanation that they’re needed for tests.

see e.g. nbconvertR

test_that('kernel tests pass', {
expect_equal(status, 0)
})