Repository: robbievanleeuwen/section-properties (language: python)

Issue:
Testing the Installation fails for test_sections
**Describe the bug**
Testing the Installation fails for test_sections due to missing files in python package and file referencing errors.
using \_\_file\_\_ instead of pathlib.Path.cwd()/... is one possible solution for referencing files in tests module.

**To Reproduce**
pytest --pyargs sectionproperties

**Expected behaviour**
Test would be run successfully

**Screenshots**
sectionproperties\tests\test_sections.py ......F.FFFF.....                                                                                                             [ 94%]
==================== FAILURES ====================
_____ test_geometry_from_dxf ___
    def test_geometry_from_dxf():
        section_holes_dxf = (
            pathlib.Path.cwd() / "sectionproperties" / "tests" / "section_holes.dxf"

**Desktop (please complete the following information):**
 - OS: Windows-10
 - Version 2.0.3

**Additional context**
section_holes.dxf and other non python files are missing from python package
![image](https://user-images.githubusercontent.com/1210784/170816205-994aa965-bc30-4bb3-b12a-7af602b03c18.png)
![image](https://user-images.githubusercontent.com/1210784/170816225-c4175d2a-4157-4b36-b7e4-f3a2d2b41bb9.png)


Testing the Installation fails for test_sections
**Describe the bug**
Testing the Installation fails for test_sections due to missing files in python package and file referencing errors.
using \_\_file\_\_ instead of pathlib.Path.cwd()/... is one possible solution for referencing files in tests module.

**To Reproduce**
pytest --pyargs sectionproperties

**Expected behaviour**
Test would be run successfully

**Screenshots**
sectionproperties\tests\test_sections.py ......F.FFFF.....                                                                                                             [ 94%]
==================== FAILURES ====================
_____ test_geometry_from_dxf ___
    def test_geometry_from_dxf():
        section_holes_dxf = (
            pathlib.Path.cwd() / "sectionproperties" / "tests" / "section_holes.dxf"

**Desktop (please complete the following information):**
 - OS: Windows-10
 - Version 2.0.3

**Additional context**
section_holes.dxf and other non python files are missing from python package
![image](https://user-images.githubusercontent.com/1210784/170816205-994aa965-bc30-4bb3-b12a-7af602b03c18.png)
![image](https://user-images.githubusercontent.com/1210784/170816225-c4175d2a-4157-4b36-b7e4-f3a2d2b41bb9.png)




Discussion / hints:
Thanks for opening your first issue in *sectionproperties* :raised_hands: Pull requests are always welcome :wink:
Thanks for opening your first issue in *sectionproperties* :raised_hands: Pull requests are always welcome :wink:

Fix patch:
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 00000000..9bee8fb6
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,5 @@
+global-include *.3dm
+global-include *.dxf
+global-include *.json
+include sectionproperties/tests/complex_shape.txt
+include sectionproperties/tests/compound_shape.txt


Test patch:
diff --git a/sectionproperties/tests/test_sections.py b/sectionproperties/tests/test_sections.py
index 39fc4ce2..f4e1dfad 100644
--- a/sectionproperties/tests/test_sections.py
+++ b/sectionproperties/tests/test_sections.py
@@ -1,5 +1,5 @@
-import pathlib
 import pytest
+from pathlib import Path
 
 from sectionproperties.pre.geometry import *
 from sectionproperties.pre.library.primitive_sections import *
@@ -241,9 +241,8 @@ def test_multi_nested_compound_geometry_from_points():
 
 
 def test_geometry_from_dxf():
-    section_holes_dxf = (
-        pathlib.Path.cwd() / "sectionproperties" / "tests" / "section_holes.dxf"
-    )
+    section_holes_dxf = Path(__file__).parent.absolute() / "section_holes.dxf"
+    print(section_holes_dxf)
     assert (
         Geometry.from_dxf(section_holes_dxf).geom.wkt
         == "POLYGON ((-0.338658834889 -0.395177702895, -0.338658834889 29.092318216393, 31.962257588776 29.092318216393, 31.962257588776 -0.395177702895, -0.338658834889 -0.395177702895), (16.684315862478 2.382629883704, 29.683030851053 2.382629883704, 29.683030851053 24.355800152063, 16.684315862478 24.355800152063, 16.684315862478 2.382629883704), (1.548825807288 3.344178663681, 14.547540795863 3.344178663681, 14.547540795863 27.382898163101, 1.548825807288 27.382898163101, 1.548825807288 3.344178663681))"
@@ -315,19 +314,15 @@ def test_plastic_centroid():
 
 
 def test_geometry_from_3dm_file_simple():
-    section = pathlib.Path.cwd() / "sectionproperties" / "tests" / "3in x 2in.3dm"
+    section = Path(__file__).parent.absolute() / "3in x 2in.3dm"
     exp = Polygon([(0, 0), (0, 3), (2, 3), (2, 0), (0, 0)])
     test = Geometry.from_3dm(section)
     assert (test.geom - exp).is_empty
 
 
 def test_geometry_from_3dm_file_complex():
-    section_3dm = (
-        pathlib.Path.cwd() / "sectionproperties" / "tests" / "complex_shape.3dm"
-    )
-    section_wkt = (
-        pathlib.Path.cwd() / "sectionproperties" / "tests" / "complex_shape.txt"
-    )
+    section_3dm = Path(__file__).parent.absolute() / "complex_shape.3dm"
+    section_wkt = Path(__file__).parent.absolute() / "complex_shape.txt"
     with open(section_wkt) as file:
         wkt_str = file.readlines()
     exp = wkt.loads(wkt_str[0])
@@ -336,12 +331,8 @@ def test_geometry_from_3dm_file_complex():
 
 
 def test_geometry_from_3dm_file_compound():
-    section_3dm = (
-        pathlib.Path.cwd() / "sectionproperties" / "tests" / "compound_shape.3dm"
-    )
-    section_wkt = (
-        pathlib.Path.cwd() / "sectionproperties" / "tests" / "compound_shape.txt"
-    )
+    section_3dm = Path(__file__).parent.absolute() / "compound_shape.3dm"
+    section_wkt = Path(__file__).parent.absolute() / "compound_shape.txt"
     with open(section_wkt) as file:
         wkt_str = file.readlines()
     exp = [wkt.loads(wkt_str[0]), wkt.loads(wkt_str[1])]
@@ -350,7 +341,7 @@ def test_geometry_from_3dm_file_compound():
 
 
 def test_geometry_from_3dm_encode():
-    section_3dm = pathlib.Path.cwd() / "sectionproperties" / "tests" / "rhino_data.json"
+    section_3dm = Path(__file__).parent.absolute() / "rhino_data.json"
     with open(section_3dm) as file:
         brep_encoded = json.load(file)
     exp = Polygon([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)])