コード例 #1
0
ファイル: tests.py プロジェクト: Fabian1976/mios-report
 def test_numpy(self):
     # Test to see whether numpy arrays work correctly
     # Must have numpy installed to do this test correctly
     data = [10,20,30,40,50,60,70,80,90]
     try:
         from numpy import array
         data = array(data)
     except ImportError:
         _print('Warning: numpy must be installed to do this test correctly')
     G = Radar(data, encoding='text')
     G.size(200,200)    
     self._test_a_chart(repr(self), G)
     return G
コード例 #2
0
ファイル: tests.py プロジェクト: rvanlaar/google-chartwrapper
 def test_numpy(self):
     # Test to see whether numpy arrays work correctly
     # Must have numpy installed to do this test correctly
     data = [10, 20, 30, 40, 50, 60, 70, 80, 90]
     try:
         from numpy import array
         data = array(data)
     except ImportError:
         _print(
             'Warning: numpy must be installed to do this test correctly')
     G = Radar(data, encoding='text')
     G.size(200, 200)
     self._test_a_chart(repr(self), G)
     return G
コード例 #3
0
ファイル: tests.py プロジェクト: rvanlaar/google-chartwrapper
    def test_extended_encode(self):
        self._test_encoding('extended', 'e:AH-HAA..', [7, 3975, 0, 4095], 4095)


def get_chart(chart):
    return getattr(TestChartTypes('test_%s' % chart), 'test_%s' % chart)()


def saveall():
    import os
    if not os.path.isdir('tests'):
        os.mkdir('tests')
    for chart in TestChartTypes.all:
        chartobj = get_chart(chart)
        chartobj.save('tests/%s' % chart)


if __name__ == '__main__':
    import sys
    calls = {
        'unit': lambda: unittest.main(),
        'save': lambda: saveall(),
    }
    arg = sys.argv[-1]
    sys.argv = sys.argv[:-1]
    if arg in calls:
        calls[arg]()
    else:
        for chart in TestChartTypes.all:
            _print(chart, '\t', get_chart(chart))
コード例 #4
0
ファイル: tests.py プロジェクト: Fabian1976/mios-report
    def test_text_encode(self):
        self._test_encoding('text', 't:0.0,10.0,100.0,-1.0,-1.0', [0,10,100,-1,-1], (0,100))
   
    def test_extended_encode(self):
        self._test_encoding('extended', 'e:AH-HAA..', [7,3975,0,4095], 4095)

def get_chart(chart):
    return getattr(TestChartTypes('test_%s'%chart), 'test_%s'%chart)()

def saveall():
    import os
    if not os.path.isdir('tests'):
        os.mkdir('tests')
    for chart in TestChartTypes.all:
        chartobj = get_chart(chart)
        chartobj.save('tests/%s'%chart)

if __name__ == '__main__':
    import sys
    calls = {
        'unit': lambda: unittest.main(),
        'save': lambda: saveall(),
    }
    arg = sys.argv[-1]
    sys.argv = sys.argv[:-1]
    if arg in calls:
        calls[arg]()
    else:
        for chart in TestChartTypes.all:
            _print( chart,'\t',get_chart(chart))
コード例 #5
0
ファイル: tests.py プロジェクト: fay/Nankin
def test():
    arg = sys.argv[-1].lower()
    if not arg in ('save','wiki','img','url','show','tags','unit'):
        arg = 'url'

    if arg == 'save':
        if not os.path.isdir('tests'):
            os.mkdir('tests')
        for test in Test.all:
            getattr(Test,test)().save(os.path.join(os.getcwd(),'tests',test))

    elif arg == 'unit':
        suite = unittest.TestLoader().loadTestsFromTestCase(ChartsTest)
        unittest.TextTestRunner(verbosity=2).run(suite)

    elif arg == 'wiki':
        links = []
        for n,test in enumerate(ordering):
            testobj = getattr(Test,test)
            G = testobj()
            title = test.title().replace('_','-')
            _print('----')
            links.append(title)
            _print('=== %s ==='%title)
            _print('{{{') #'{{{\n#!python'
            _print( '\n'.join(map(lambda x: x[8:], getsource(testobj).splitlines()[1:-1])) )
            _print('}}}')
            #print '{{{\n#!html'
            _print('%s&.png'%G) #G.img()
            #print '}}}'
            _print()
        for link in links:
            _print('  * [http://code.google.com/p/google-chartwrapper/wiki/ChartExamples#%s %s]'%(link,link))
    elif arg == 'tags':
        _print("""{% load charts %} <table><tr>
        <th> Advanced </th><td>
{%  chart lc 4.0 93.0 42.0 48.8 70.0 99.0  encoding=text %}
    {% scale 4 100 %}
    {%  axes type xy  %}
    {%  axes label Mar  Apr  May  June  July   %}
    {%  axes label None  50+K   %}
    {%  color ff0000   %}
    {%  line 6 5 2   %}
        {% img alt=DataScaling height=400 id=img title=DataSaling %}
    {%  size 400 200   %}
{% endchart %} </td></tr>""")
        for test in Test.all:
#            if test in ('multiline','axes_position','venn','guide_meter'): continue
            _print('<tr><th>%s</th><td>'%test.title().replace('_','-'))
            src = []
            for l in map(lambda x: x.strip(), getsource(getattr(Test,test)).splitlines()[1:-1]):
                if l.startswith('#') or not l.strip():
                    continue
                elif l.startswith('G ='):
                    l = 'chart '+l.split('(')[0].split('G =')[1] +' ' + '('.join(l.split('(')[1:])

                rmlst = ['G.',']','[',"'"] # __setattr__
                splst = ["','",'(',')',','] # __call__
                for s in splst:
                    l = l.replace(s,' ')
                for r in rmlst:
                    l = l.replace(r,'')
                l = l.replace('axes.','axes ')
                if l.find('encoding')==0:
                    l = l.replace('=',' ')
                src.append('{% '+l+' %}')
            src.append('{% endchart %}')
            src = '\n'.join(src)
            _print(src,'</td><td><pre>',src.replace('{','&#123;').replace('}','&#125;'),'</pre></td></tr>')
        _print('</table>')
    elif arg == 'img':
        for test in Test.all:
            _print(test,'\t',getattr(Test,test)().img())
            _print()

    elif arg == 'url':
        for test in ordering:
            _print(test,'\t',getattr(Test,test)())
            _print()

    elif arg == 'show':
        for test in Test.all:
            getattr(Test,test)().show()