from pathlib import Path


def test_readme():
    with open('README.md') as f:
        readme = f.read()

        bundled = Path(__file__).parent.parent \
            .joinpath('thefuck') \
            .joinpath('rules') \
            .glob('*.py')

        for rule in bundled:
            if rule.stem != '__init__' and rule.stem not in readme:
                raise Exception('Missing rule "{}" in README.md'.format(rule.stem))


if __name__ == '__main__':
    test_readme()

@@ -47,17 +47,82 @@
     
-with open
+project_root = Path(__file__).parent.parent%0A    with project_root.joinpath
 ('RE
@@ -130,16 +130,23 @@
 DME.md')
+.open()
  as f:%0A 
@@ -193,35 +193,19 @@
 d = 
-Path(__file__).parent.paren
+project_roo
 t %5C%0A
@@ -370,12 +370,32 @@
 t__'
- and
+:%0A                assert
  rul
@@ -405,12 +405,8 @@
 tem 
-not 
 in r
@@ -410,17 +410,18 @@
 n readme
-:
+,%5C
 %0A       
@@ -433,24 +433,12 @@
     
-raise Exception(
+    
 'Mis
@@ -487,53 +487,5 @@
 tem)
-)%0A%0A%0Aif __name__ == '__main__':%0A    test_readme()
 %0A

Improve readme test