-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
RF: always close old figure windows #3916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tacaswell
merged 3 commits into
matplotlib:master
from
matthew-brett:plot-directive-old-figures
Jan 2, 2015
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
# Make tests a package |
This file contains hidden or 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,85 @@ | ||
""" Tests for tinypages build using sphinx extensions """ | ||
|
||
import shutil | ||
import tempfile | ||
|
||
from os.path import (join as pjoin, dirname, isdir) | ||
|
||
from subprocess import call, Popen, PIPE | ||
|
||
from nose import SkipTest | ||
from nose.tools import assert_true | ||
|
||
HERE = dirname(__file__) | ||
TINY_PAGES = pjoin(HERE, 'tinypages') | ||
|
||
|
||
def setup(): | ||
# Check we have the sphinx-build command | ||
try: | ||
ret = call(['sphinx-build', '--help'], stdout=PIPE, stderr=PIPE) | ||
except OSError: | ||
raise SkipTest('Need sphinx-build on path for these tests') | ||
if ret != 0: | ||
raise RuntimeError('sphinx-build does not return 0') | ||
|
||
|
||
def file_same(file1, file2): | ||
with open(file1, 'rb') as fobj: | ||
contents1 = fobj.read() | ||
with open(file2, 'rb') as fobj: | ||
contents2 = fobj.read() | ||
return contents1 == contents2 | ||
|
||
|
||
class TestTinyPages(object): | ||
# Test build and output of tinypages project | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
cls.page_build = tempfile.mkdtemp() | ||
try: | ||
cls.html_dir = pjoin(cls.page_build, 'html') | ||
cls.doctree_dir = pjoin(cls.page_build, 'doctrees') | ||
# Build the pages with warnings turned into errors | ||
cmd = ['sphinx-build', '-W', '-b', 'html', | ||
'-d', cls.doctree_dir, | ||
TINY_PAGES, | ||
cls.html_dir] | ||
proc = Popen(cmd, stdout=PIPE, stderr=PIPE) | ||
out, err = proc.communicate() | ||
except Exception as e: | ||
shutil.rmtree(cls.page_build) | ||
raise e | ||
if proc.returncode != 0: | ||
shutil.rmtree(cls.page_build) | ||
raise RuntimeError('sphinx-build failed with stdout:\n' | ||
'{0}\nstderr:\n{1}\n'.format( | ||
out, err)) | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
shutil.rmtree(cls.page_build) | ||
|
||
def test_some_plots(self): | ||
assert_true(isdir(self.html_dir)) | ||
|
||
def plot_file(num): | ||
return pjoin(self.html_dir, 'some_plots-{0}.png'.format(num)) | ||
|
||
range_10, range_6, range_4 = [plot_file(i) for i in range(1, 4)] | ||
# Plot 5 is range(6) plot | ||
assert_true(file_same(range_6, plot_file(5))) | ||
# Plot 7 is range(4) plot | ||
assert_true(file_same(range_4, plot_file(7))) | ||
# Plot 11 is range(10) plot | ||
assert_true(file_same(range_10, plot_file(11))) | ||
# Plot 12 uses the old range(10) figure and the new range(6) figure | ||
assert_true(file_same(range_10, plot_file('12_00'))) | ||
assert_true(file_same(range_6, plot_file('12_01'))) | ||
# Plot 13 shows close-figs in action | ||
assert_true(file_same(range_4, plot_file(13))) | ||
# Plot 14 has included source | ||
with open(pjoin(self.html_dir, 'some_plots.html'), 'rt') as fobj: | ||
html_contents = fobj.read() | ||
assert_true('# Only a comment' in html_contents) |
This file contains hidden or 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 @@ | ||
_build/ |
This file contains hidden or 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,3 @@ | ||
# Test project for matplotlib sphinx extensions | ||
|
||
A tiny sphinx project from ``sphinx-quickstart`` with all default answers. |
Empty file.
This file contains hidden or 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,7 @@ | ||
############################## | ||
Static directory for tinypages | ||
############################## | ||
|
||
We need this README file to make sure the ``_static`` directory gets created | ||
in the installation. The tests check for warnings in builds, and, when the | ||
``_static`` directory is absent, this raises a warning. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also remove the sphinx installation on line 30?