Esempio n. 1
0
def test_findsource():
    from py._code.source import findsource
    co = py.code.compile("""if 1:
    def x():
        pass
""")

    src, lineno = findsource(co)
    assert 'if 1:' in str(src)

    d = {}
    eval(co, d)
    src, lineno = findsource(d['x'])
    assert 'if 1:' in str(src)
    assert src[lineno] == "    def x():"
Esempio n. 2
0
def test_findsource():
    from py._code.source import findsource
    co = py.code.compile("""if 1:
    def x():
        pass
""")

    src, lineno = findsource(co)
    assert 'if 1:' in str(src)

    d = {}
    eval(co, d)
    src, lineno = findsource(d['x'])
    assert 'if 1:' in str(src)
    assert src[lineno] == "    def x():"
Esempio n. 3
0
    def fullsource(self):
        """ return a py.code.Source object for the full source file of the code
        """
        from py._code import source

        full, _ = source.findsource(self.raw)
        return full
Esempio n. 4
0
    def fullsource(self):
        """ return a py.code.Source object for the full source file of the code
        """
        from py._code import source

        full, _ = source.findsource(self.raw)
        return full
Esempio n. 5
0
def test_findsource_fallback():
    from py._code.source import findsource
    src, lineno = findsource(x)
    assert 'test_findsource_simple' in str(src)
    assert src[lineno] == '    def x():'
Esempio n. 6
0
def test_findsource_fallback():
    from py._code.source import findsource
    src, lineno = findsource(x)
    assert 'test_findsource_simple' in str(src)
    assert src[lineno] == '    def x():'