Exemplo n.º 1
0
    def test_graph(self) :
        """
        This test is failing with Python 3.4 if many pictures are drawn.
        """
        fLOG (__file__, self._testMethodName, OutputPrint = __name__ == "__main__")

        cache = os.path.abspath(os.path.split(__file__)[0])
        cache = os.path.join(cache, "temp_cache2")
        stocks = [ StockPrices ("BNP.PA", folder = cache),
                    StockPrices ("CA.PA", folder = cache),
                    StockPrices ("SAF.PA", folder = cache),
                    ]
                    
        if True:
            fig, ax, plt = StockPrices.draw(stocks, figsize=(16,8), field = ["Adj Close", "Close"])
            img = os.path.abspath(os.path.join(os.path.split(__file__)[0],"temp_image.png"))
            if os.path.exists(img): os.remove(img)
            fig.savefig(img)
            assert os.path.exists(img)

        if True and sys.version_info < (3,4) :
            fig, ax, plt = StockPrices.draw(stocks, begin="2010-01-01")
            img = os.path.abspath(os.path.join(os.path.split(__file__)[0],"temp_image2.png"))
            if os.path.exists(img): os .remove(img)
            fig.savefig(img)
            assert os.path.exists(img)
            
        if True and sys.version_info < (3,4):
            fig, ax, plt = StockPrices.draw(stocks[:1], begin="2010-01-01")
            img = os.path.abspath(os.path.join(os.path.split(__file__)[0],"temp_image3.png"))
            if os.path.exists(img): os .remove(img)
            fig.savefig(img)
            assert os.path.exists(img)     
    def test_graph(self):
        """
        This test is failing with Python 3.4 if many pictures are drawn.
        """
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        fix_tkinter_issues_virtualenv()

        from matplotlib import pyplot as plt

        cache = os.path.abspath(os.path.split(__file__)[0])
        cache = os.path.join(cache, "temp_cache2")
        stocks = [StockPrices(t, folder=cache, url=TestStockGraph.source)
                  for t in TestStockGraph.tick]

        if True:
            fLOG("A", sys.executable)
            fig, ax = plt.subplots()
            ax = StockPrices.draw(
                stocks, figsize=(
                    16, 8), field=[
                    "Open", "Close"],
                ax=ax)
            img = os.path.abspath(
                os.path.join(
                    os.path.split(__file__)[0],
                    "temp_image.png"))
            if os.path.exists(img):
                os.remove(img)
            fig.savefig(img)
            plt.close('all')
            self.assertExists(img)

        if True:
            fLOG("B")
            fig, ax = plt.subplots()
            ax = StockPrices.draw(stocks, begin="2010-01-01", ax=ax)
            img = os.path.abspath(
                os.path.join(
                    os.path.split(__file__)[0],
                    "temp_image2.png"))
            if os.path.exists(img):
                os .remove(img)
            fig.savefig(img)
            plt.close('all')
            self.assertExists(img)

        if True:
            fLOG("C")
            fig, ax = plt.subplots()
            ax = StockPrices.draw(stocks[:1], begin="2010-01-01", ax=ax)
            img = os.path.abspath(
                os.path.join(
                    os.path.split(__file__)[0],
                    "temp_image3.png"))
            if os.path.exists(img):
                os .remove(img)
            fig.savefig(img)
            plt.close('all')
            self.assertExists(img)

        fLOG("thisend")
Exemplo n.º 3
0
    def test_graph(self):
        """
        This test is failing with Python 3.4 if many pictures are drawn.
        """
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        fix_tkinter_issues_virtualenv()

        from matplotlib import pyplot as plt

        cache = os.path.abspath(os.path.split(__file__)[0])
        cache = os.path.join(cache, "temp_cache2")
        stocks = [StockPrices("BNP.PA", folder=cache),
                  StockPrices("CA.PA", folder=cache),
                  StockPrices("SAF.PA", folder=cache),
                  ]

        if True:
            fLOG("A", sys.executable)
            fig, ax = plt.subplots()
            ax = StockPrices.draw(
                stocks, figsize=(
                    16, 8), field=[
                    "Adj Close", "Close"],
                ax=ax)
            img = os.path.abspath(
                os.path.join(
                    os.path.split(__file__)[0],
                    "temp_image.png"))
            if os.path.exists(img):
                os.remove(img)
            fig.savefig(img)
            plt.close('all')
            assert os.path.exists(img)

        if True:
            fLOG("B")
            fig, ax = plt.subplots()
            ax = StockPrices.draw(stocks, begin="2010-01-01", ax=ax)
            img = os.path.abspath(
                os.path.join(
                    os.path.split(__file__)[0],
                    "temp_image2.png"))
            if os.path.exists(img):
                os .remove(img)
            fig.savefig(img)
            plt.close('all')
            assert os.path.exists(img)

        if True:
            fLOG("C")
            fig, ax = plt.subplots()
            ax = StockPrices.draw(stocks[:1], begin="2010-01-01", ax=ax)
            img = os.path.abspath(
                os.path.join(
                    os.path.split(__file__)[0],
                    "temp_image3.png"))
            if os.path.exists(img):
                os .remove(img)
            fig.savefig(img)
            plt.close('all')
            assert os.path.exists(img)

        fLOG("thisend")