File: test_pylab.py

package info (click to toggle)
python-networkx 1.9%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,052 kB
  • ctags: 3,986
  • sloc: python: 52,132; makefile: 176
file content (40 lines) | stat: -rw-r--r-- 941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
    Unit tests for matplotlib drawing functions.
"""

import os

from nose import SkipTest

import networkx as nx

class TestPylab(object):
    @classmethod
    def setupClass(cls):
        global plt
        try:
            import matplotlib as mpl
            mpl.use('PS',warn=False)
            import matplotlib.pyplot as plt
        except ImportError:
            raise SkipTest('matplotlib not available.')
        except RuntimeError:
            raise SkipTest('matplotlib not available.')

    def setUp(self):
        self.G=nx.barbell_graph(5,10)


    def test_draw(self):
        N=self.G
        nx.draw_spring(N)
        plt.savefig("test.ps")
        nx.draw_random(N)
        plt.savefig("test.ps")
        nx.draw_circular(N)
        plt.savefig("test.ps")
        nx.draw_spectral(N)
        plt.savefig("test.ps")
        nx.draw_spring(N.to_directed())
        plt.savefig("test.ps")
        os.unlink('test.ps')