Forráskód Böngészése

Renommage exemples

Benoît Hubert 7 éve
szülő
commit
743b59d27e

examples/debut.py → examples/4-bases-python-tdd/1-premier-programme.py


examples/functions.py → examples/4-bases-python-tdd/2-fonctions.py


examples/03-classes-starwars.py → examples/4-bases-python-tdd/3-classes-starwars.py


+ 12 - 0
examples/5-mini-serveur-http/mini-serveur-ft.py

@@ -0,0 +1,12 @@
+from selenium import webdriver
+
+# Instance de Firefox contrôlée par webdriver
+browser = webdriver.Firefox()
+
+# On pointe ce browser vers l'URL de notre mini-serveur
+browser.get('http://localhost:8081')
+
+# En toute logique, on voudrait que le HTML généré par notre serveur ait un titre
+assert 'Mini-Serveur' in browser.title
+
+browser.quit()

+ 11 - 1
examples/mini-serveur.py

@@ -1,5 +1,14 @@
 from http.server import BaseHTTPRequestHandler, HTTPServer
 
+base_html = """<!DOCTYPE html>
+<html>
+  <head>
+    <title>Mini-Serveur</title>
+  </head>
+  <body>{body}</body>
+</html>
+"""
+
 # HTTPRequestHandler class
 class MiniHTTPServerRequestHandler(BaseHTTPRequestHandler):
 
@@ -13,7 +22,8 @@ class MiniHTTPServerRequestHandler(BaseHTTPRequestHandler):
         self.end_headers()
 
         # Send message back to client
-        message = "Hello world!"
+        message = base_html.replace("{body}", "Hello world!")
+
         # Write content as utf-8 data
         self.wfile.write(bytes(message, "utf8"))
         return

+ 0 - 33
examples/mini-serveur-ft.py

@@ -1,33 +0,0 @@
-from selenium import webdriver
-
-browser = webdriver.Firefox()
-
-# Edith has heard about a cool new online to-do app. She goes
-# to check out its homepage
-browser.get('http://localhost:8081')
-
-# She notices the page title and header mention to-do lists
-assert 'Mini-Serveur' in browser.title
-
-# She is invited to enter a to-do item straight away
-
-# She types "Buy peacock feathers" into a text box (Edith's hobby
-# is tying fly-fishing lures)
-
-# When she hits enter, the page updates, and now the page lists
-# "1: Buy peacock feathers" as an item in a to-do list
-
-# There is still a text box inviting her to add another item. She
-# enters "Use peacock feathers to make a fly" (Edith is very methodical)
-
-# The page updates again, and now shows both items on her list
-
-# Edith wonders whether the site will remember her list. Then she sees
-# that the site has generated a unique URL for her -- there is some
-# explanatory text to that effect.
-
-# She visits that URL - her to-do list is still there.
-
-# Satisfied, she goes back to sleep
-
-browser.quit()

+ 1 - 1
react-tuto/src/markdown/4. Bases de Python/05. TDD - exemple.md

@@ -2,7 +2,7 @@ Un exemple : on veut écrire une fonction, qui nous renvoie une valeur booléenn
 
 #### Le test
 
-D'abord le test :
+D'abord le test, que tu peux créer dans `exemples/4-bases-python-tdd/5-tdd-exemple.py` :
 
 ```python
 import unittest

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
react-tuto/src/resources/markdown.json