コード例 #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():"
コード例 #2
0
ファイル: test_source.py プロジェクト: pexip/os-python-py
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():"
コード例 #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
コード例 #4
0
ファイル: code.py プロジェクト: carriercomm/glasshouse
    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
コード例 #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():'
コード例 #6
0
ファイル: test_source.py プロジェクト: pexip/os-python-py
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():'