-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""hello_world_3 | ||
Module for 'Hello, World!' program - part 3 | ||
""" | ||
|
||
greeting = "Hello, World!" | ||
if greeting: | ||
if greeting: | ||
print(greeting) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,47 @@ | ||
import pytest | ||
from pftp.codealong import CodeAlong, CodeAlongWriter | ||
from pathlib import Path | ||
|
||
@pytest.fixture() | ||
def hello_world() -> CodeAlong: | ||
"""An example CodeAlong writer""" | ||
class HelloWorld(CodeAlong): | ||
|
||
def __init__(self): | ||
super().__init__("Hello World", | ||
sections=[ | ||
self.hello_world_1, | ||
self.hello_world_2, | ||
] | ||
) | ||
|
||
def hello_world_1(self) -> None: | ||
"""Module for 'Hello, World!' program - part 1""" | ||
class TestCodeAlongWriter: | ||
|
||
def test_func_to_str(self): | ||
def f() -> None: | ||
"""A function, f""" | ||
|
||
print("Hello, World!") | ||
|
||
def hello_world_2(self) -> None: | ||
"""Module for 'Hello, World!' program - part 2""" | ||
|
||
if __name__ == "__main__": | ||
print("Hello, World!") | ||
|
||
return HelloWorld | ||
|
||
def test_codealong(hello_world: CodeAlong): | ||
from pathlib import Path | ||
writer = CodeAlongWriter() | ||
actual = writer.func_to_filestring(f) | ||
|
||
writer = CodeAlongWriter(hello_world(), indent_amount=3) | ||
root_dir = Path("./test/codealong") | ||
writer.write(root_dir) | ||
expected = '''"""f | ||
expected = '''"""hello_world_1 | ||
Module for 'Hello, World!' program - part 1 | ||
A function, f | ||
""" | ||
print("Hello, World!") | ||
''' | ||
|
||
assert (root_dir/"hello_world_1.py").read_text() == expected | ||
assert actual == expected | ||
|
||
def test_func_to_str_multiline_docstring(self): | ||
def f() -> None: | ||
""" | ||
A function, f | ||
""" | ||
|
||
print("Hello, World!") | ||
|
||
expected = '''"""hello_world_2 | ||
writer = CodeAlongWriter() | ||
actual = writer.func_to_filestring(f) | ||
|
||
Module for 'Hello, World!' program - part 2 | ||
expected = '''"""f | ||
A function, f | ||
""" | ||
if __name__ == "__main__": | ||
print("Hello, World!") | ||
print("Hello, World!") | ||
''' | ||
assert actual == expected | ||
|
||
assert (root_dir/"hello_world_2.py").read_text() == expected | ||
|
||
def test_codealong_multiple_idents(): | ||
assert False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters