The male lawmakers attacked Amy Ndiaye after she criticised an opposition religious figure.
The judge also ordered Mamadou Niang and Massata Samb to pay Ms Ndiaye five million CFA francs ($8,100; £6,750) in compensation.
The incident was widely condemned and sparked a debate about women’s rights.
Ms Ndiaye, a member of the ruling Benno Bokk Yakaar coalition, fainted in parliament after the attack and there were fears that she would lose the baby.
Despite the video evidence, lawyers for Mr Niang and Mr Samb argued in court that their clients had not physically attacked Ms Ndiaye.
They also argued unsuccessfully that the two lawmakers were immune to prosecution.
“They are going to remain in prison pending an appeal,” one of their lawyers, Abdy Nar Ndiaye, told AFP.
There has been tension in Senegal’s parliament since the government lost its majority in legislative elections in July last year.
BBC