lovasoa: The tests fail because the code does not follow [black](https://black.readthedocs.io/en/stable/) formatting
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 982f4eb..ffe5fdc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # marshmallow_dataclass change log
 
+## v7.1.1
+ - Fix behavior when `base_schema` is passed to a nested dataclass/schema
+   ([#52](https://github.com/lovasoa/marshmallow_dataclass/issues/52)).
+   Thanks [@ADR-007-SoftServe](https://github.com/ADR-007-SoftServe)
+   for the catch and patch.
+
 ## v7.1.0
  - Improved documentation
  - The library now has more unit tests
diff --git a/marshmallow_dataclass/__init__.py b/marshmallow_dataclass/__init__.py
index a9b3119..a2dd954 100644
--- a/marshmallow_dataclass/__init__.py
+++ b/marshmallow_dataclass/__init__.py
@@ -117,7 +117,7 @@ def add_schema(_cls: Type[_U]) -> Type[_U]:
 
 @overload
 def add_schema(
-    base_schema: Type[marshmallow.Schema] = None
+    base_schema: Type[marshmallow.Schema] = None,
 ) -> Callable[[Type[_U]], Type[_U]]:
     ...
 
@@ -422,9 +422,15 @@ def field_for_schema(
 
         return marshmallow_enum.EnumField(typ, **metadata)
 
+    # Nested marshmallow dataclass
+    nested_schema = getattr(typ, "Schema", None)
+
     # Nested dataclasses
     forward_reference = getattr(typ, "__forward_arg__", None)
-    nested = forward_reference or class_schema(typ, base_schema=base_schema)
+    nested = (
+        nested_schema or forward_reference or class_schema(typ, base_schema=base_schema)
+    )
+
     return marshmallow.fields.Nested(nested, **metadata)
 
 

`base_schema` of nested dataclasses is ingored
The base_schema of the nested field is ignored.

## Example:
```py
from marshmallow import Schema, post_dump
from marshmallow_dataclass import dataclass


class DoubleSchema(Schema):
    @post_dump
    def double(self, data, **kwargs):
        return dict(double=data['number'] * 2)


@dataclass(base_schema=DoubleSchema)
class A:
    number: int


@dataclass
class B:
    a: A


print('is A.Schema correct?', issubclass(A.Schema, DoubleSchema))
print('is B.a.Schema correct?', isinstance(B.Schema._declared_fields['a'].schema, DoubleSchema))
print()

print('expected:')
print("    {'a': {'double': 2}}")
print('actual:')
print('   ', B.Schema().dump(B(A(1))))

```
stdout:
```
is A.Schema correct? True
is B.a.Schema correct? False

expected:
    {'a': {'double': 2}}
actual:
    {'a': {'number': 1}}
```

## How to fix
```diff
--- marshmallow_dataclass/__init__.py   2019-11-25 14:59:36.146392038 +0200
+++ marshmallow_dataclass/__init__.py.fixed     2019-11-25 15:01:01.947898497 +0200
@@ -422,9 +422,12 @@ def field_for_schema(
 
+    # Nested marshmellow dataclass
+    nested_schema = getattr(typ, 'Schema', None)
+
     # Nested dataclasses
     forward_reference = getattr(typ, "__forward_arg__", None)
-    nested = forward_reference or class_schema(typ, base_schema=base_schema)
+    nested = nested_schema or forward_reference or class_schema(typ, base_schema=base_schema)
     return marshmallow.fields.Nested(nested, **metadata)

```
diff --git a/tests/test_field_for_schema.py b/tests/test_field_for_schema.py
index 4d8b0a0..8f356e9 100644
--- a/tests/test_field_for_schema.py
+++ b/tests/test_field_for_schema.py
@@ -1,11 +1,12 @@
+import inspect
 import typing
 import unittest
 from enum import Enum
 from typing import Dict, Optional, Union, Any
 
-from marshmallow import fields
+from marshmallow import fields, Schema
 
-from marshmallow_dataclass import field_for_schema
+from marshmallow_dataclass import field_for_schema, dataclass
 
 
 class TestFieldForSchema(unittest.TestCase):
@@ -13,7 +14,11 @@ class TestFieldForSchema(unittest.TestCase):
         self.assertEqual(a.__class__, b.__class__, "field class")
 
         def attrs(x):
-            return {k: repr(v) for k, v in x.__dict__.items() if not k.startswith("_")}
+            return {
+                k: f"{v!r} ({v.__mro__!r})" if inspect.isclass(v) else repr(v)
+                for k, v in x.__dict__.items()
+                if not k.startswith("_")
+            }
 
         self.assertEqual(attrs(a), attrs(b))
 
@@ -97,6 +102,19 @@ class TestFieldForSchema(unittest.TestCase):
             fields.Integer(required=False, description="UserId", default=0, missing=0),
         )
 
+    def test_marshmallow_dataclass(self):
+        class NewSchema(Schema):
+            pass
+
+        @dataclass(base_schema=NewSchema)
+        class NewDataclass:
+            pass
+
+        self.assertFieldsEqual(
+            field_for_schema(NewDataclass, metadata=dict(required=False)),
+            fields.Nested(NewDataclass.Schema),
+        )
+
 
 if __name__ == "__main__":
     unittest.main()

pip install -e .[dev]
parse_log_pytest
pytest
pytest
apt-get update apt-get install -y gcc
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
aspy.yaml==1.3.0
attrs @ file:///croot/attrs_1668696182826/work
Babel==2.14.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cfgv==3.3.1
charset-normalizer==3.4.1
distlib==0.3.9
docutils==0.19
filelock==3.12.2
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
identify==2.5.24
idna==3.10
imagesize==1.4.1
importlib-metadata==6.7.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Jinja2==3.1.6
MarkupSafe==2.1.5
marshmallow==3.19.0
-e git+https://github.com/lovasoa/marshmallow_dataclass.git@2de0d398d63e2f783867bfded6a9276326effda1#egg=marshmallow_dataclass
marshmallow-enum==1.5.1
marshmallow-union==0.1.15.post1
mypy-extensions==1.0.0
nodeenv==1.9.1
packaging @ file:///croot/packaging_1671697413597/work
platformdirs==4.0.0
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
pre-commit==1.21.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
Pygments==2.17.2
pytest==7.1.2
pytz==2025.2
PyYAML==6.0.1
requests==2.31.0
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
toml==0.10.2
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing-inspect==0.9.0
typing_extensions==4.7.1
urllib3==2.0.7
virtualenv==20.26.6
zipp @ file:///croot/zipp_1672387121353/work

name: marshmallow_dataclass
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - aspy-yaml==1.3.0
      - babel==2.14.0
      - cfgv==3.3.1
      - charset-normalizer==3.4.1
      - distlib==0.3.9
      - docutils==0.19
      - filelock==3.12.2
      - identify==2.5.24
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==6.7.0
      - jinja2==3.1.6
      - markupsafe==2.1.5
      - marshmallow==3.19.0
      - marshmallow-dataclass==7.1.0
      - marshmallow-enum==1.5.1
      - marshmallow-union==0.1.15.post1
      - mypy-extensions==1.0.0
      - nodeenv==1.9.1
      - platformdirs==4.0.0
      - pre-commit==1.21.0
      - pygments==2.17.2
      - pytz==2025.2
      - pyyaml==6.0.1
      - requests==2.31.0
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - toml==0.10.2
      - typing-extensions==4.7.1
      - typing-inspect==0.9.0
      - urllib3==2.0.7
      - virtualenv==20.26.6
prefix: /opt/conda/envs/marshmallow_dataclass

tests/test_field_for_schema.py::TestFieldForSchema::test_marshmallow_dataclass
tests/test_field_for_schema.py::TestFieldForSchema::test_any tests/test_field_for_schema.py::TestFieldForSchema::test_builtin_dict tests/test_field_for_schema.py::TestFieldForSchema::test_builtin_list tests/test_field_for_schema.py::TestFieldForSchema::test_dict_from_typing tests/test_field_for_schema.py::TestFieldForSchema::test_enum tests/test_field_for_schema.py::TestFieldForSchema::test_explicit_field tests/test_field_for_schema.py::TestFieldForSchema::test_int tests/test_field_for_schema.py::TestFieldForSchema::test_newtype tests/test_field_for_schema.py::TestFieldForSchema::test_optional_str tests/test_field_for_schema.py::TestFieldForSchema::test_str tests/test_field_for_schema.py::TestFieldForSchema::test_union
CHANGELOG.md marshmallow_dataclass/__init__.py
CHANGELOG.md marshmallow_dataclass/__init__.py