Skip to content

Commit

Permalink
Fix module names of C module objects (fixes #128) (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
GjjvdBurg authored Jun 15, 2024
1 parent a49cb88 commit 80b7fc5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/abstraction.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static struct PyMethodDef cabstraction_methods[] = {

static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"ccsv.cabstraction",
"clevercsv.cabstraction",
cabstraction_module_doc,
-1,
cabstraction_methods,
Expand Down
4 changes: 2 additions & 2 deletions src/cparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ static struct PyMethodDef cparser_methods[] = {

static struct PyModuleDef _cparsermodule = {
PyModuleDef_HEAD_INIT,
"ccsv.cparser",
"clevercsv.cparser",
cparser_module_doc,
sizeof(_cparserstate),
cparser_methods,
Expand Down Expand Up @@ -727,7 +727,7 @@ PyMODINIT_FUNC PyInit_cparser(void)


/* Add the CSV exception object to the module. */
_cparserstate(module)->error_obj = PyErr_NewException("cparser.Error", NULL, NULL);
_cparserstate(module)->error_obj = PyErr_NewException("clevercsv.cparser.Error", NULL, NULL);
if (_cparserstate(module)->error_obj == NULL)
return NULL;
Py_INCREF(_cparserstate(module)->error_obj);
Expand Down
23 changes: 23 additions & 0 deletions tests/test_unit/test_c_file_naming.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest

import clevercsv


class CNamingTestCase(unittest.TestCase):
def test_name_cabstraction_module(self) -> None:
self.assertEqual(
clevercsv.cabstraction.__name__, "clevercsv.cabstraction"
)

def test_name_cparser_module(self) -> None:
self.assertEqual(clevercsv.cparser.__name__, "clevercsv.cparser")

def test_name_cparser_error(self) -> None:
self.assertEqual(
clevercsv.cparser.Error.__module__, "clevercsv.cparser"
)

def test_name_cparser_parser(self) -> None:
self.assertEqual(
clevercsv.cparser.Parser.__module__, "clevercsv.cparser"
)

0 comments on commit 80b7fc5

Please sign in to comment.