Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ffd4074

Browse files
committed
Some more work on creating a "clean" rcParams environment for running tests.
svn path=/trunk/matplotlib/; revision=7729
1 parent 8ee6651 commit ffd4074

3 files changed

Lines changed: 14 additions & 21 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -894,16 +894,20 @@ def test(verbosity=0):
894894
from testing.noseclasses import KnownFailure
895895
from nose.plugins.manager import PluginManager
896896

897+
# Store the current backend and all rcParams for restoration later
897898
backend = rcParams['backend']
899+
original_params = rcParams.copy()
898900

899901
use('Agg') # use Agg backend for these tests
900902

901-
# store the old values before overriding
902-
overrides = 'font.family', 'text.hinting'
903-
stored = dict([(k, rcParams[k]) for k in overrides])
904-
903+
# These settings *must* be hardcoded for running the comparison
904+
# tests and are not necessarily the default values as specified in
905+
# rcsetup.py
906+
rcdefaults() # Start with all defaults
905907
rcParams['font.family'] = 'Bitstream Vera Sans'
906908
rcParams['text.hinting'] = False
909+
910+
# store the old values before overriding
907911
plugins = []
908912
plugins.append( KnownFailure() )
909913
plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] )
@@ -914,11 +918,10 @@ def test(verbosity=0):
914918
success = nose.run( defaultTest=default_test_modules,
915919
config=config,
916920
)
917-
# restore the old rc values
918-
rcParams.update(stored)
919921

920-
# restore the old backend
922+
# restore the old backend and rcParams
921923
use(backend)
924+
rcParams.update(original_params)
922925
return success
923926

924927
test.__test__ = False # nose: this function is not a test

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,7 @@ class FontProperties(object):
642642
The preferred usage of font sizes is to use the relative values,
643643
e.g. 'large', instead of absolute font sizes, e.g. 12. This
644644
approach allows all text sizes to be made larger or smaller based
645-
on the font manager's default font size, i.e. by using the
646-
:meth:`FontManager.set_default_size` method.
645+
on the font manager's default font size.
647646
648647
This class will also accept a `fontconfig
649648
<http://www.fontconfig.org/>`_ pattern, if it is the only argument
@@ -1022,23 +1021,14 @@ def get_default_size(self):
10221021
"""
10231022
Return the default font size.
10241023
"""
1025-
if self.default_size is None:
1026-
return rcParams['font.size']
1027-
return self.default_size
1024+
return rcParams['font.size']
10281025

10291026
def set_default_weight(self, weight):
10301027
"""
10311028
Set the default font weight. The initial value is 'normal'.
10321029
"""
10331030
self.__default_weight = weight
10341031

1035-
def set_default_size(self, size):
1036-
"""
1037-
Set the default font size in points. The initial value is set
1038-
by ``font.size`` in rc.
1039-
"""
1040-
self.default_size = size
1041-
10421032
def update_fonts(self, filenames):
10431033
"""
10441034
Update the font dictionary with new font files.

test/matplotlibrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
backend : Agg
2-
font.family : sans-serif
3-
font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
2+
font.family : Bitstream Vera Sans
3+
text.hinting : True

0 commit comments

Comments
 (0)