[writer] план helloworld (конвейер DevHub)
This commit is contained in:
parent
0b372b6c07
commit
cb98e2fa75
|
|
@ -0,0 +1,90 @@
|
||||||
|
# План приложения helloworld
|
||||||
|
|
||||||
|
## Структура проекта
|
||||||
|
|
||||||
|
```
|
||||||
|
helloworld/
|
||||||
|
├── src/
|
||||||
|
│ └── main.py
|
||||||
|
├── tests/
|
||||||
|
│ └── test_main.py
|
||||||
|
├── .gitignore
|
||||||
|
├── README.md
|
||||||
|
└── requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Файлы
|
||||||
|
|
||||||
|
1. **src/main.py**
|
||||||
|
```python
|
||||||
|
def say_hello():
|
||||||
|
return "Hello, World!"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(say_hello())
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **tests/test_main.py**
|
||||||
|
```python
|
||||||
|
import unittest
|
||||||
|
from src.main import say_hello
|
||||||
|
|
||||||
|
class TestMain(unittest.TestCase):
|
||||||
|
def test_say_hello(self):
|
||||||
|
self.assertEqual(say_hello(), "Hello, World!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **.gitignore**
|
||||||
|
```
|
||||||
|
/tests/__pycache__/
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **README.md**
|
||||||
|
```markdown
|
||||||
|
# helloworld
|
||||||
|
Простое приложение на Python, выводящее "Hello, World!".
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **requirements.txt**
|
||||||
|
```
|
||||||
|
# No external dependencies required
|
||||||
|
```
|
||||||
|
|
||||||
|
## Шаги сборки
|
||||||
|
|
||||||
|
1. Создайте новый каталог для проекта `helloworld`.
|
||||||
|
2. Создайте файл `src/main.py` и вставьте в него код:
|
||||||
|
```python
|
||||||
|
def say_hello():
|
||||||
|
return "Hello, World!"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(say_hello())
|
||||||
|
```
|
||||||
|
3. Создайте каталог `tests` и файл `tests/test_main.py` с кодом:
|
||||||
|
```python
|
||||||
|
import unittest
|
||||||
|
from src.main import say_hello
|
||||||
|
|
||||||
|
class TestMain(unittest.TestCase):
|
||||||
|
def test_say_hello(self):
|
||||||
|
self.assertEqual(say_hello(), "Hello, World!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
```
|
||||||
|
4. Создайте файл `.gitignore` с содержимым:
|
||||||
|
```
|
||||||
|
/tests/__pycache__/
|
||||||
|
```
|
||||||
|
5. Создайте файл `README.md` с содержимым:
|
||||||
|
```markdown
|
||||||
|
# helloworld
|
||||||
|
Простое приложение на Python, выводящее "Hello, World!".
|
||||||
|
```
|
||||||
|
6. Создайте файл `requirements.txt` и оставьте его пустым, так как нет внешних зависимостей.
|
||||||
|
7. В терминале перейдите в каталог `helloworld` и выполните команду `python -m unittest tests/test_main.py` для запуска тестов.
|
||||||
|
8. Если тесты прошли успешно, приложение готово к использованию.
|
||||||
Loading…
Reference in New Issue